Exemplo n.º 1
0
 /**
  *
  */
 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);
 }
Exemplo n.º 2
0
Arquivo: FileTask.php Projeto: chh/bob
 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;
 }
Exemplo n.º 3
0
Arquivo: Task.php Projeto: chh/bob
 function getTaskPrerequisites()
 {
     $app = $this->application;
     return itertools\filter(itertools\to_iterator($this->prerequisites), function ($task) use($app) {
         return $app->taskDefined($task);
     });
 }
Exemplo n.º 4
0
 function remove($predicate)
 {
     $this->iterator = itertools\filter($this->getIterator(), static::identityFn($predicate, true));
     return $this;
 }
Exemplo n.º 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));
 }