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