public function getIterator() { $func = $this->func; foreach ($this->inner as $current) { $accept = Helper\LinqHelper::getBoolOrThrowException($func($current)); if ($accept) { (yield $current); } } }
/** * Determines whether any element exists or satisfies a condition by invoking $func. * * @param callable $func A function to test each element for a condition or NULL to determine if any element exists. * @return bool True if no $func given and the source sequence contains any elements or True if any elements passed the test in the specified func; otherwise, false. */ public function any(callable $func = null) { foreach ($this->iterator as $current) { if ($func === null) { return true; } $match = LinqHelper::getBoolOrThrowException($func($current)); if ($match) { return true; } } return false; }
public function accept() { $func = $this->func; $current = $this->current(); return Helper\LinqHelper::getBoolOrThrowException($func($current)); }