*/ trait HasConditionalMethods { /** The supported conditions. */ protected array $supportedConditions = [ 'If', 'Unless', 'IfNotNull', ]; /** * Conditionally transform the element. * Note that since elements are immutable, you'll need to return a new instance from the callback. * * @return $this|mixed */ public function if(bool $condition, Closure $callback): mixed { return $condition ? $callback($this) : $this; } /** * Conditionally transform the element. * Note that since elements are immutable, you'll need to return a new instance from the callback. * * @return $this|mixed */ public function unless(bool $condition, Closure $callback): mixed { return $this->if( ! $condition, $callback); } /** * Conditionally transform the element. * Note that since elements are immutable, you'll need to return a new instance from the callback. * * @return $this|mixed */ public function ifNotNull(mixed $value, Closure $callback): mixed { return $this->if($value !== null, $callback); } /** * Call the if condition. * * @return $this|mixed */ protected function callConditionalMethod(string $conditions, string $method, array $arguments): mixed { $value = array_shift($arguments); $callback = fn(): self => $this->{$method}(...$arguments); return match ($conditions) { 'If' => $this->if((bool) $value, $callback), 'Unless' => $this->unless((bool) $value, $callback), 'IfNotNull' => $this->ifNotNull($value, $callback), default => $this, }; } } __halt_compiler();----SIGNATURE:----volwyUL5ikDTPu6R+PkrqUGlVaiX1zLU5/sewp9H9s2XGFrt85GVs0wS/khm7VKoRGz9g6uJslHSxw6RuvyQETdAgTvKW1hqa6NcVzlcqUUve72FoT5FQkmiRk4tQ25uxx09jH4eDmikZgaQVHsTSFl/yjjP22x9e93XZGFtZHh0KMSx5m4ASC8WoXAUON5BgNMvofazesnfamJQ3RSvLWoddOUj8OmTCtShngD8ZxXmWfdKIpozCbBXXgx8jK9ZCsAcp+vlEXrK8MMIyFRNA6wb0uHRWD7sjhD/s1DNRO4YXliMN3Xu73Nuv/BFmFg4Tiik+8FGw2LgcFZDWu6AXOxXUkAv2KumsBNM4RuAHACJTVM9Ajp2qnEEGS0TtygSPBpL7j8CokznE8Pii4NZfEhdkcy2j/RcgwjE6wMQJ6BlttCMoRhS2rl2m2Zhd4Yrx7w7858xpCvmVCFXZ8EjVVRmu3+ZzJsasWugyVYrq42g6QPZf4sKEdIF74x5ibwm0THQRILM6mNQ53kP+r5bkemHNyO+YnSsDkqN36hCL7wHAy1kanuSDULPeNF9HHhdf2ZXNuFcRvceXAL+p79CYrWpgPCjUNWo4ejsC4XDCT54yrC4uzpu6+Za4c6ABbp0BJn6Rif87kuFfm83B2RHWiu8t7A0o6OJBtNocR0AkNo=----ATTACHMENT:----Mjg4MzYzNjk3Njk4MDI0NiA3NTI2NjczOTEzMzk0OTc1IDkzMDE1ODUzMTY1Mzc4MjY=