| Total Complexity | 5 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class DBOptionalValue implements OptionalValue { |
||
| 8 | /** |
||
| 9 | * @param object|array<string, mixed> $data |
||
| 10 | * @param string|string[] $path |
||
| 11 | * @param null|callable(): bool $validator |
||
| 12 | */ |
||
| 13 | public function __construct( |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @return bool |
||
| 21 | */ |
||
| 22 | public function isValid(): bool { |
||
| 23 | if(!RecursiveStructureAccess::recursiveHas($this->data, $this->path)) { |
||
| 24 | return false; |
||
| 25 | } |
||
| 26 | if($this->validator !== null) { |
||
| 27 | $value = $this->getValue(); |
||
| 28 | |||
| 29 | return call_user_func($this->validator, $value); |
||
| 30 | } |
||
| 31 | |||
| 32 | return true; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @return mixed|null |
||
| 37 | */ |
||
| 38 | public function getValue() { |
||
| 40 | } |
||
| 41 | } |
||
| 42 |