| Total Complexity | 3 |
| Total Lines | 43 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | class AbstractValidator |
||
| 18 | { |
||
| 19 | /** |
||
| 20 | * Array of valid strings |
||
| 21 | * |
||
| 22 | * @var array |
||
| 23 | */ |
||
| 24 | protected array $haystack = []; |
||
| 25 | |||
| 26 | /** |
||
| 27 | * Return true, if $value is valid. False otherwise. |
||
| 28 | * |
||
| 29 | * @param string $value |
||
| 30 | * |
||
| 31 | * @return bool |
||
| 32 | */ |
||
| 33 | 4 | public function isValid(string $value): bool |
|
| 34 | { |
||
| 35 | 4 | return in_array($value, $this->getHaystack(), true); |
|
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Get the array of valid strings |
||
| 40 | * |
||
| 41 | * @return array |
||
| 42 | */ |
||
| 43 | 4 | protected function getHaystack(): array |
|
| 44 | { |
||
| 45 | 4 | return $this->haystack; |
|
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Set the array of valid strings |
||
| 50 | * |
||
| 51 | * @param array $haystack |
||
| 52 | * |
||
| 53 | * @return $this |
||
| 54 | */ |
||
| 55 | 4 | protected function setHaystack(array $haystack): self |
|
| 60 | } |
||
| 61 | } |
||
| 62 |