Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 12 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
25 | 2 | public function isValid($value, array $parameters) |
|
26 | { |
||
27 | |||
28 | 2 | if (in_array($value, [null, ''])) { |
|
29 | 2 | return true; |
|
30 | } |
||
31 | |||
32 | 1 | $data = $parameters[0]; |
|
33 | 1 | $field = $parameters[1]; |
|
34 | 1 | $manyEntity = $data->getDefinition()->getSubTypeField($field, 'many', 'entity'); |
|
35 | 1 | $validIds = array_keys($data->getIdToNameMap($manyEntity, null)); |
|
36 | 1 | $candidateIds = array_column($value, 'id'); |
|
37 | |||
38 | 1 | foreach ($candidateIds as $candidateId) { |
|
39 | 1 | if (!in_array($candidateId, $validIds)) { |
|
40 | 1 | return false; |
|
41 | } |
||
42 | } |
||
43 | |||
44 | 1 | return true; |
|
45 | } |
||
46 | |||
56 |