callback = $callback; parent::__construct($options); } /** * Get the haystack, invoking the callback if no haystack has been set * * @return mixed[] */ public function getHaystack(): array { return $this->haystack ?? call_user_func($this->callback); } /** * Set the callback * * @param callable $callback * * @return $this */ public function setCallback(callable $callback): static { $this->haystack = null; $this->callback = $callback; return $this; } }