1 | <?php |
||
19 | class UniqueValidator implements ValidatorInterface { |
||
20 | |||
21 | /** |
||
22 | * Checks whether the unique constraint is valid for a many-to-many field. |
||
23 | * |
||
24 | * @param array $value |
||
25 | * the value to check |
||
26 | * @param AbstractData $data |
||
27 | * the data to perform the check with |
||
28 | * @param Entity $entity |
||
29 | * the entity to perform the check on |
||
30 | * @param $field |
||
31 | * the many field to perform the check on |
||
32 | * |
||
33 | * @return boolean |
||
34 | * true if it is a valid unique many-to-many constraint |
||
35 | */ |
||
36 | protected function isValidUniqueMany(array $value, AbstractData $data, Entity $entity, $field) { |
||
39 | |||
40 | /** |
||
41 | * Performs the regular unique validation. |
||
42 | * |
||
43 | * @param $value |
||
44 | * the value to validate |
||
45 | * @param $data |
||
46 | * the data instance to validate with |
||
47 | * @param $entity |
||
48 | * the entity of the field |
||
49 | * @param $field |
||
50 | * the field to validate |
||
51 | * |
||
52 | * @return boolean |
||
53 | * true if everything is valid |
||
54 | */ |
||
55 | protected function isValidUnique($value, AbstractData $data, Entity $entity, $field) |
||
66 | |||
67 | /** |
||
68 | * {@inheritdoc} |
||
69 | */ |
||
70 | public function isValid($value, array $parameters) { |
||
87 | |||
88 | /** |
||
89 | * {@inheritdoc} |
||
90 | */ |
||
91 | public function getInvalidDetails() { |
||
94 | |||
95 | } |
||
96 |
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.