| Total Complexity | 4 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class AuthorFixtures extends Fixture implements OrderedFixtureInterface |
||
| 14 | { |
||
| 15 | private $idGenerator; |
||
| 16 | |||
| 17 | public function __construct(IdGenerator $idGenerator) |
||
| 18 | { |
||
| 19 | $this->idGenerator = $idGenerator; |
||
| 20 | } |
||
| 21 | |||
| 22 | public function getOrder(): int |
||
| 23 | { |
||
| 24 | return 100; |
||
| 25 | } |
||
| 26 | |||
| 27 | public function load(ObjectManager $manager): void |
||
| 28 | { |
||
| 29 | $data = [ |
||
| 30 | 'shakespeare' => 'William Shakespeare', |
||
| 31 | 'christie' => 'Agatha Christie', |
||
| 32 | ]; |
||
| 33 | |||
| 34 | foreach ($data as $alias => $fullName) { |
||
| 35 | $author = new Author($this->idGenerator->authorId(), $fullName); |
||
| 36 | |||
| 37 | $this->addReference('author-' . $alias, $author); |
||
| 38 | |||
| 39 | $manager->persist($author); |
||
| 40 | } |
||
| 41 | |||
| 42 | $manager->flush(); |
||
| 43 | } |
||
| 45 |