| Conditions | 5 |
| Paths | 5 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | 3 | public static function validateModel(ReflectionClass $reflectionClass): ValidationResult |
|
| 18 | { |
||
| 19 | 3 | $validationResult = new ValidationResult(); |
|
| 20 | 3 | foreach ($reflectionClass->getProperties() as $reflectionProperty) { |
|
| 21 | 2 | if (in_array(Visibility::PUBLIC->value, Reflection::getModifierNames($reflectionProperty->getModifiers()), true) === false) { |
|
| 22 | 1 | continue; |
|
| 23 | } |
||
| 24 | |||
| 25 | 1 | foreach ($reflectionProperty->getAttributes() as $reflectionAttribute) { |
|
| 26 | 1 | if ($reflectionAttribute->newInstance() instanceof Rule) { |
|
| 27 | 1 | $validationResult->addError('Public properties can\'t have validation rules, but a public property with name "' . $reflectionProperty->getName() . '" does.'); |
|
| 28 | |||
| 29 | 1 | break; |
|
| 30 | } |
||
| 31 | } |
||
| 32 | } |
||
| 33 | |||
| 34 | 3 | return $validationResult; |
|
| 35 | } |
||
| 37 |