Parkour\Traverse::every PHP Method

every() public static method

Returns true if every element of the given data passes a thruth test.
public static every ( array $data, callable $cb ) : boolean
$data array Data.
$cb callable Test.
return boolean If every element passes the test.
    public static function every(array $data, callable $cb)
    {
        foreach ($data as $key => $value) {
            if (!call_user_func($cb, $value, $key)) {
                return false;
            }
        }
        return true;
    }

Usage Example

 /**
  *
  */
 public function testEvery()
 {
     $data = [1, 2];
     $closure = $this->closure([[1, 0, false]]);
     $this->assertFalse(Traverse::every($data, $closure));
     $closure = $this->closure([[1, 0, true], [2, 1, true]]);
     $this->assertTrue(Traverse::every($data, $closure));
 }