Ejemplo n.º 1
0
 public function getIterator()
 {
     $func = $this->func;
     foreach ($this->inner as $current) {
         $accept = Helper\LinqHelper::getBoolOrThrowException($func($current));
         if ($accept) {
             (yield $current);
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * 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;
 }
Ejemplo n.º 3
0
 public function accept()
 {
     $func = $this->func;
     $current = $this->current();
     return Helper\LinqHelper::getBoolOrThrowException($func($current));
 }