| Total Complexity | 6 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | class CurrentMetaData |
||
| 9 | { |
||
| 10 | private $metadata; |
||
| 11 | |||
| 12 | private $manager; |
||
| 13 | |||
| 14 | private $currentMetadata; |
||
| 15 | |||
| 16 | 1 | private function __construct(EntityManagerInterface $manager) |
|
| 17 | { |
||
| 18 | 1 | $this->manager = $manager; |
|
| 19 | |||
| 20 | 1 | $metadata = $this->manager |
|
| 21 | 1 | ->getMetaDataFactory() |
|
| 22 | 1 | ->getAllMetaData(); |
|
| 23 | |||
| 24 | 1 | $this->metadata = $metadata; |
|
| 25 | 1 | } |
|
| 26 | |||
| 27 | 1 | public static function fromEntityManager(EntityManagerInterface $manager) : CurrentMetaData |
|
| 28 | { |
||
| 29 | 1 | return new self($manager); |
|
| 30 | } |
||
| 31 | |||
| 32 | public function justEntitiesMetadata() : array |
||
| 33 | { |
||
| 34 | 1 | return array_map(function ($item) { |
|
| 35 | 1 | return $item->rootEntityName; |
|
| 36 | 1 | }, $this->metadata); |
|
| 37 | } |
||
| 38 | |||
| 39 | 1 | public function extractFields($entityClass) : array |
|
| 40 | { |
||
| 41 | 1 | $this->currentMetadata = $this->manager->getClassMetadata($entityClass); |
|
| 42 | |||
| 43 | 1 | return array_map(function ($item) { |
|
| 44 | 1 | return Dictionary::getOperatorsFromDoctrineType($item['type']); |
|
| 45 | 1 | }, $this->currentMetadata->fieldMappings); |
|
|
|
|||
| 46 | } |
||
| 47 | |||
| 48 | 1 | public function haveRelations() : bool |
|
| 49 | { |
||
| 50 | return isset( |
||
| 51 | 1 | $this->currentMetadata->associationMappings['members'] |
|
| 52 | ); |
||
| 53 | } |
||
| 54 | |||
| 55 | 1 | public function getCurrentTargetEntity() : string |
|
| 60 | } |
||
| 61 | } |
||
| 62 |