Total Complexity | 8 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | class Property |
||
10 | { |
||
11 | /** |
||
12 | * @var EntityManagerInterface |
||
13 | */ |
||
14 | private $em; |
||
15 | |||
16 | public function __construct(EntityManagerInterface $em) |
||
17 | { |
||
18 | $this->em = $em; |
||
19 | } |
||
20 | |||
21 | /** |
||
22 | * @TODO Support for relations is missing |
||
23 | */ |
||
24 | public function getFakerMethodFromDoctrineFieldMappings(ReflectionClass $entity): array |
||
25 | { |
||
26 | $properties = []; |
||
27 | $classMetaData = $this->em->getClassMetadata($entity->getName()); |
||
28 | $identifierFieldNames = $classMetaData->getIdentifierFieldNames(); |
||
29 | |||
30 | foreach ($classMetaData->fieldMappings as $property) { |
||
31 | // IGNORE FIELD IF IDENTIFIER |
||
32 | if (\in_array($property['fieldName'], $identifierFieldNames)) { |
||
33 | continue; |
||
34 | } |
||
35 | |||
36 | // CREATE FROM DOCTRINE TYPE IF PROP IS NOT NULLABLE |
||
37 | if (!$property['nullable']) { |
||
38 | $properties[$property['fieldName']] = $this->createFakerMethodFromDoctrineType($property['type']); |
||
39 | } |
||
40 | } |
||
41 | |||
42 | return $properties; |
||
43 | } |
||
44 | |||
45 | /** |
||
46 | * @throws Exception |
||
47 | */ |
||
48 | public function createFakerMethodFromDoctrineType(string $doctrineType): string |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @TODO get relations which cant be NULL |
||
61 | */ |
||
62 | public function getPropertiesFromDoctrineRelations() |
||
64 | } |
||
65 | } |
||
66 |