Conditions | 4 |
Paths | 4 |
Total Lines | 21 |
Code Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
19 | public function create(string $className) : EntityDefinition |
||
20 | { |
||
21 | $entityReflection = new \ReflectionClass($className); |
||
22 | $methods = $entityReflection->getMethods(\ReflectionMethod::IS_PUBLIC); |
||
23 | |||
24 | $entityDefinition = new EntityDefinition($className); |
||
25 | foreach ($methods as $method) { |
||
26 | $methodName = $method->getName(); |
||
|
|||
27 | |||
28 | if (strpos($methodName, 'get') !== 0) { |
||
29 | continue; |
||
30 | } |
||
31 | |||
32 | $fieldName = $this->fieldNameMapper->map($methodName); |
||
33 | $fieldType = $method->getReturnType() === NULL ? 'string' : (string) $method->getReturnType(); |
||
34 | |||
35 | $entityDefinition->addField(new EntityFieldDefinition(lcfirst(substr($methodName, 3)), $fieldName, $fieldType)); |
||
36 | } |
||
37 | |||
38 | return $entityDefinition; |
||
39 | } |
||
40 | } |