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