| Total Complexity | 5 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 16 | class Json extends Rule |
||
| 17 | { |
||
| 18 | use HasValidationMessage; |
||
| 19 | |||
| 20 | private string $message = 'The value is not json'; |
||
| 21 | |||
| 22 | 5 | protected function validateValue($value, DataSetInterface $dataSet = null): Result |
|
| 23 | { |
||
| 24 | 5 | $result = new Result(); |
|
| 25 | |||
| 26 | 5 | if (!$this->isValidJson($value)) { |
|
| 27 | 4 | $result->addError($this->translateMessage($this->message)); |
|
| 28 | } |
||
| 29 | |||
| 30 | 5 | return $result; |
|
| 31 | } |
||
| 32 | |||
| 33 | 5 | private function isValidJson($value): bool |
|
| 46 | } |
||
| 47 | } |
||
| 48 |