| Conditions | 4 |
| Paths | 4 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | public function validate($value, Constraint $constraint) |
||
| 42 | { |
||
| 43 | if (!$value instanceof ProductInterface) { |
||
| 44 | throw new UnexpectedTypeException($value, ProductInterface::class); |
||
| 45 | } |
||
| 46 | |||
| 47 | if (!$value->isSimple()) { |
||
| 48 | return; |
||
| 49 | } |
||
| 50 | |||
| 51 | if (null !== $this->productVariantRepository->findOneBy(['code' => $value->getCode()])) { |
||
| 52 | $this->context->buildViolation($constraint->message) |
||
| 53 | ->atPath('code') |
||
| 54 | ->addViolation() |
||
| 55 | ; |
||
| 56 | } |
||
| 57 | } |
||
| 58 | } |
||
| 59 |
Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.