/**
  *
  */
 public function testFilterIterator()
 {
     $toFilter = [0, 1, 2, 3, 4, 5];
     $callback = function ($i) {
         return $i <= 3;
     };
     $filtered = to_array(filter($callback, $toFilter));
     $this->assertSame([0, 1, 2, 3], $filtered);
     $filtered = to_array(filter_false($callback, $toFilter));
     $this->assertSame([4, 5], $filtered);
 }
Exemple #2
0
 function getTimestamp()
 {
     $lastModifiedTimes = iterator_to_array(itertools\filter(itertools\map(function ($file) {
         if (file_exists($file)) {
             return @filemtime($file);
         }
     }, $this->prerequisites)));
     if ($lastModifiedTimes) {
         return max($lastModifiedTimes);
     }
     return 0;
 }
Exemple #3
0
Fichier : Task.php Projet : chh/bob
 function getTaskPrerequisites()
 {
     $app = $this->application;
     return itertools\filter(itertools\to_iterator($this->prerequisites), function ($task) use($app) {
         return $app->taskDefined($task);
     });
 }
Exemple #4
0
 function remove($predicate)
 {
     $this->iterator = itertools\filter($this->getIterator(), static::identityFn($predicate, true));
     return $this;
 }
Exemple #5
0
 function testFilterWithoutArgumentRemovesFalsyElements()
 {
     $a = new ArrayIterator(array(1, 2, null, 3, 0, false));
     $this->assertEquals(array(1, 2, 3), iterator_to_array(itertools\filter($a), false));
 }