| Total Complexity | 3 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 6 | abstract class Specification |
||
| 7 | { |
||
| 8 | /** |
||
| 9 | * Abstract implementation of isSatisfiedBy. |
||
| 10 | * Subclasses will use this method to implement their |
||
| 11 | * own contract for validation logic. |
||
| 12 | * |
||
| 13 | * @param mixed $object |
||
| 14 | * @return bool |
||
| 15 | */ |
||
| 16 | abstract public function isSatisfiedBy($object): bool; |
||
| 17 | |||
| 18 | /** |
||
| 19 | * Method to allow for chaining specifications which must all satisfy |
||
| 20 | * |
||
| 21 | * @param Specification $specification |
||
| 22 | * @return AndSpecification |
||
| 23 | */ |
||
| 24 | 2 | public function and(Specification $specification): AndSpecification |
|
| 25 | { |
||
| 26 | 2 | return new AndSpecification($this, $specification); |
|
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Method to allow for chaining specifications where at least one must satisfy |
||
| 31 | * |
||
| 32 | * @param Specification $specification |
||
| 33 | * @return OrSpecification |
||
| 34 | */ |
||
| 35 | 2 | public function or(Specification $specification): OrSpecification |
|
| 36 | { |
||
| 37 | 2 | return new OrSpecification($this, $specification); |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Method to allow for negation of a specification by forcing it to not satisfy |
||
| 42 | * |
||
| 43 | * @return NotSpecification |
||
| 44 | */ |
||
| 45 | 4 | public function not(): NotSpecification |
|
| 48 | } |
||
| 49 | } |
||
| 50 |