1 | <?php |
||
17 | final class MandatoryConditional implements Validator |
||
18 | { |
||
19 | 32 | public function check(Resource $resource) |
|
20 | { |
||
21 | 32 | foreach ($resource->mandatory() as $key => $value) { |
|
22 | 19 | if (isset($value['when']['has_value'])) { |
|
23 | 4 | $name = $value['when']['property']; |
|
24 | 4 | $value = $value['when']['has_value']; |
|
25 | |||
26 | 4 | if (is_array($value)) { |
|
27 | 3 | foreach ($value as $item) { |
|
28 | 3 | $this->ensurePropertyNameHasKey($resource, $item, $name, $key); |
|
29 | } |
||
30 | } else { |
||
31 | 1 | $this->ensurePropertyNameHasKey($resource, $value, $name, $key); |
|
32 | } |
||
33 | } |
||
34 | } |
||
35 | 30 | } |
|
36 | |||
37 | 4 | public function ensurePropertyNameHasKey(Resource $resource, $value, $name, $key) |
|
47 | } |
||
48 |