| Conditions | 4 |
| Paths | 4 |
| Total Lines | 24 |
| Code Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 28 | public function isValid($value, array $parameters) { |
||
| 29 | |||
| 30 | if (in_array($value, [null, ''])) { |
||
| 31 | return true; |
||
| 32 | } |
||
| 33 | |||
| 34 | $data = $parameters[0]; |
||
| 35 | $entity = $parameters[1]; |
||
| 36 | $field = $parameters[2]; |
||
| 37 | $type = $data->getDefinition()->getType($field); |
||
| 38 | |||
| 39 | if ($type === 'many') { |
||
| 40 | return $this->isValidUniqueMany($value, $data, $entity, $field); |
||
| 41 | } |
||
| 42 | |||
| 43 | $params = [$field => $value]; |
||
| 44 | $paramsOperators = [$field => '=']; |
||
| 45 | if ($entity->get('id') !== null) { |
||
| 46 | $params['id'] = $entity->get('id'); |
||
| 47 | $paramsOperators['id'] = '!='; |
||
| 48 | } |
||
| 49 | $amount = intval($data->countBy($data->getDefinition()->getTable(), $params, $paramsOperators, true)); |
||
| 50 | return $amount == 0; |
||
| 51 | } |
||
| 52 | |||
| 61 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.