| Total Complexity | 5 |
| Total Lines | 64 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 13 | class PlayerFixtures extends Fixture |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var array<string> |
||
| 17 | */ |
||
| 18 | private array $entities = [ |
||
| 19 | 'Player', |
||
| 20 | ]; |
||
| 21 | |||
| 22 | |||
| 23 | /** |
||
| 24 | * @var array<mixed> |
||
| 25 | */ |
||
| 26 | private array $players = [ |
||
| 27 | [ |
||
| 28 | 'id' => 11, |
||
| 29 | 'pseudo' => 'magicbart', |
||
| 30 | ], |
||
| 31 | [ |
||
| 32 | 'id' => 12, |
||
| 33 | 'pseudo' => 'kloh', |
||
| 34 | ], |
||
| 35 | [ |
||
| 36 | 'id' => 13, |
||
| 37 | 'pseudo' => 'flatine', |
||
| 38 | ], |
||
| 39 | ]; |
||
| 40 | |||
| 41 | |||
| 42 | private function updateGeneratorType(ObjectManager $manager): void |
||
| 43 | { |
||
| 44 | foreach ($this->entities as $entity) { |
||
| 45 | $metadata = $manager->getClassMetaData("VideoGamesRecords\\CoreBundle\\Entity\\" . $entity); |
||
| 46 | $metadata->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_NONE); |
||
| 47 | } |
||
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * @throws Exception |
||
| 52 | */ |
||
| 53 | public function load(ObjectManager $manager): void |
||
| 54 | { |
||
| 55 | $this->updateGeneratorType($manager); |
||
| 56 | $this->loadPlayers($manager); |
||
| 57 | $manager->flush(); |
||
| 58 | } |
||
| 59 | |||
| 60 | |||
| 61 | /** |
||
| 62 | * @param ObjectManager $manager |
||
| 63 | */ |
||
| 64 | private function loadPlayers(ObjectManager $manager): void |
||
| 77 | } |
||
| 78 | } |
||
| 79 | } |
||
| 80 |