add negate alias for not method of predicate

This commit is contained in:
Kacper Donat 2018-07-15 20:50:11 +02:00
parent 596031d09e
commit c9392f9b12
2 changed files with 8 additions and 1 deletions

View File

@ -15,6 +15,7 @@ interface Predicate
public function __invoke(...$args): bool;
public function not(): Predicate;
public function negate(): Predicate; // should ALWAYS be alias for not
public function and(...$predicate): Predicate;
public function or(...$predicate): Predicate;

View File

@ -10,9 +10,10 @@
namespace Kadet\Functional\Predicate;
use Kadet\Functional\Decorator;
use Kadet\Functional\Predicate;
class NegatedPredicate extends AbstractPredicate
class NegatedPredicate extends AbstractPredicate implements Decorator
{
/**
* Predicate to be negated.
@ -35,4 +36,9 @@ class NegatedPredicate extends AbstractPredicate
{
return !($this->negated)(...$args);
}
public function getDecorated()
{
$this->negated;
}
}