Test Setup Failed
Branch master (354693)
by Valery
10:57
created

AreaFixtures   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 30
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 11 2
A getDependencies() 0 4 1
A getAreaData() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\DataFixtures;
6
7
use App\Entity\Area;
8
use Doctrine\Bundle\FixturesBundle\Fixture;
9
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
10
use Doctrine\Common\Persistence\ObjectManager;
11
12
final class AreaFixtures extends Fixture implements DependentFixtureInterface
13
{
14
    public function load(ObjectManager $manager): void
15
    {
16
        foreach ($this->getAreaData() as [$locality, $name, $slug]) {
17
            $area = new Area();
18
            $area->setLocality($locality);
19
            $area->setName($name);
20
            $area->setSlug($slug);
21
            $manager->persist($area);
22
            $this->addReference($name, $area);
23
        }
24
        $manager->flush();
25
    }
26
27
    private function getAreaData(): array
28
    {
29
        return [
30
            // $areaData = [$locality, $name, $slug];
31
           [$this->getReference('Miami'), 'South Beach', 'south-beach'],
32
           [$this->getReference('Miami'), 'Downtown', 'downtown'],
33
           [$this->getReference('Tampa'), 'Ballast Point', 'ballast-point'],
34
           [$this->getReference('Tampa'), 'Culbreath Isles', 'culbreath-isles'],
35
        ];
36
    }
37
38
    public function getDependencies()
39
    {
40
        return [
41
            LocalityFixtures::class,
42
        ];
43
    }
44
}
45