Example #1
0
 public function testNot()
 {
     $even = UnaryPredicate(function ($value) {
         return $value % 2 === 0;
     });
     $odd = Predicates::not($even);
     for ($i = 0; $i < 100; $i++) {
         $this->assertEquals(!$even->test($i), $odd->test($i));
     }
 }
Example #2
0
/**
 * Creates the opposite predicate for a given predicate.
 *
 * @param PredicateInterface $predicate
 *            The given predicate.
 * @return PredicateInterface
 */
function not(PredicateInterface $predicate) : PredicateInterface
{
    return Predicates::not($predicate);
}