count() public static method

Example: $array = array(1, 2, 3); $count = Arrays::count($array, function ($element) { return $element < 3; }); Result: 2
public static count ( array $elements, callable $predicate ) : integer
$elements array
$predicate callable
return integer
Exemplo n.º 1
0
 /**
  * @test
  */
 public function shouldCountElements()
 {
     //given
     $array = array(1, 2, 3);
     //when
     $count = Arrays::count($array, function ($element) {
         return $element < 3;
     });
     //then
     $this->assertEquals(2, $count);
 }