add negate alias for not method of predicate
This commit is contained in:
parent
596031d09e
commit
c9392f9b12
@ -15,6 +15,7 @@ interface Predicate
|
|||||||
public function __invoke(...$args): bool;
|
public function __invoke(...$args): bool;
|
||||||
|
|
||||||
public function not(): Predicate;
|
public function not(): Predicate;
|
||||||
|
public function negate(): Predicate; // should ALWAYS be alias for not
|
||||||
|
|
||||||
public function and(...$predicate): Predicate;
|
public function and(...$predicate): Predicate;
|
||||||
public function or(...$predicate): Predicate;
|
public function or(...$predicate): Predicate;
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
namespace Kadet\Functional\Predicate;
|
namespace Kadet\Functional\Predicate;
|
||||||
|
|
||||||
|
|
||||||
|
use Kadet\Functional\Decorator;
|
||||||
use Kadet\Functional\Predicate;
|
use Kadet\Functional\Predicate;
|
||||||
|
|
||||||
class NegatedPredicate extends AbstractPredicate
|
class NegatedPredicate extends AbstractPredicate implements Decorator
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Predicate to be negated.
|
* Predicate to be negated.
|
||||||
@ -35,4 +36,9 @@ class NegatedPredicate extends AbstractPredicate
|
|||||||
{
|
{
|
||||||
return !($this->negated)(...$args);
|
return !($this->negated)(...$args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getDecorated()
|
||||||
|
{
|
||||||
|
$this->negated;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user