Conditions | 5 |
Paths | 5 |
Total Lines | 18 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 5.2 |
Changes | 0 |
1 | <?php |
||
17 | 28 | private function getTypeFromSetter(PropertyMetadata $propertyMetadata, ClassMetadata $classMetadata) |
|
18 | { |
||
19 | 28 | $setterName = sprintf('set%s', ucfirst($propertyMetadata->name)); |
|
20 | |||
21 | 28 | $setter = $classMetadata->methodMetadata[$setterName] ?? null; |
|
22 | |||
23 | 28 | if ($setter instanceof MethodMetadata) { |
|
24 | 15 | $params = $setter->reflection->getParameters(); |
|
25 | |||
26 | 15 | if (count($params) == 0) { |
|
27 | throw new Exception("setter method {$classMetadata->name}:{$setterName} has no params"); |
||
28 | } |
||
29 | |||
30 | 15 | if (count($params) > 1) { |
|
31 | throw new Exception("setter method {$classMetadata->name}:{$setterName} has more than one param"); |
||
32 | } |
||
33 | |||
34 | 15 | return $params[0]->getClass() ? $params[0]->getClass()->name : null; |
|
35 | } |
||
38 |