| Conditions | 4 |
| Paths | 4 |
| Total Lines | 15 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 5.024 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | 12 | public function check(Resource $resource) |
|
| 20 | { |
||
| 21 | 12 | foreach ($resource->properties() as $key => $value) { |
|
| 22 | 8 | if (isset($resource->allowedValues()[$key])) { |
|
| 23 | 2 | $allowedValues = $resource->allowedValues()[$key]; |
|
| 24 | 2 | if (!in_array($value, $allowedValues)) { |
|
| 25 | throw new \Sensorario\Resources\Exceptions\UnexpectedValueException( |
||
| 26 | 'Value `' . $value . '` is not allowed ' |
||
| 27 | . 'for key `' . $key . '`. ' |
||
| 28 | . 'Allowed values are: ' . var_export($allowedValues, true) |
||
| 29 | ); |
||
| 30 | } |
||
| 31 | } |
||
| 32 | } |
||
| 33 | 12 | } |
|
| 34 | } |
||
| 35 |