all() public method

This method short-circuits, so if any item does not match the predicate, no further elements are considered.
public all ( callable $predicate = null ) : boolean
$predicate callable
return boolean
Example #1
0
 public function testAll()
 {
     $stream = new Stream([1, 4, 9, 16, 25]);
     // All these integers are truthy.
     $this->assertTrue($stream->all());
     // Not all of them are even.
     $this->assertFalse($stream->all(function ($value) {
         return $value % 2 == 0;
     }));
     // All of these are squares.
     $this->assertTrue($stream->all(function ($value) {
         $root = round(sqrt($value));
         return $root * $root == $value;
     }));
 }