Conditions | 2 |
Paths | 1 |
Total Lines | 12 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php namespace Pz\Doctrine\Rest\Traits; |
||
14 | 4 | protected function validateEntity($entity) |
|
15 | { |
||
16 | 4 | $errors = Validation::createValidatorBuilder() |
|
17 | 4 | ->enableAnnotationMapping() |
|
18 | 4 | ->getValidator() |
|
19 | 4 | ->validate($entity); |
|
20 | |||
21 | 4 | if ($errors->count() > 0) { |
|
22 | 1 | throw RestException::createFromConstraintViolationList($errors); |
|
23 | } |
||
24 | |||
25 | 3 | return $entity; |
|
26 | } |
||
28 |