| 1 | <?php |
||
| 19 | final class InstanceOfPredicate implements Predicate |
||
| 20 | { |
||
| 21 | protected $type; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * InstanceOdPredicate constructor. |
||
| 25 | * |
||
| 26 | * @param string $type The type to check for. |
||
| 27 | */ |
||
| 28 | 3 | public function __construct(string $type) |
|
| 32 | |||
| 33 | /** |
||
| 34 | * Gets the type to compare to. |
||
| 35 | * |
||
| 36 | * @return string The type. |
||
| 37 | */ |
||
| 38 | 1 | public function getType() : string |
|
| 39 | { |
||
| 40 | 1 | return $this->type; |
|
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * Evaluates the predicate returning true if the input value is of the correct type. |
||
| 45 | * |
||
| 46 | * @param mixed $value The input value |
||
| 47 | * @return bool true if input is of stored type. |
||
| 48 | */ |
||
| 49 | 2 | public function __invoke($value) : bool |
|
| 53 | } |
||
| 54 |