callable = $callable; } /** * The make constructor. * * @param callable $callable * @return self */ public static function make( callable $callable ): self { return new static( $callable ); } /** * Invokes a callable once and returns the same result on subsequent invokes. * * @param mixed ...$args Arguments to be passed to the callable. * @return mixed */ public function __invoke( ...$args ) { if ( ! $this->executed ) { $this->result = call_user_func_array( $this->callable, $args ); $this->executed = true; } return $this->result; } }