FeatureFixtures::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 10
rs 10
c 1
b 0
f 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\DataFixtures;
6
7
use App\Entity\Feature;
8
use Doctrine\Bundle\FixturesBundle\Fixture;
9
use Doctrine\Persistence\ObjectManager;
10
11
final class FeatureFixtures extends Fixture
12
{
13
    public function load(ObjectManager $manager): void
14
    {
15
        foreach ($this->getFeatureData() as [$name, $icon]) {
16
            $feature = new Feature();
17
            $feature->setName($name);
18
            $feature->setIcon($icon);
19
            $manager->persist($feature);
20
            $this->addReference($name, $feature);
21
        }
22
        $manager->flush();
23
    }
24
25
    private function getFeatureData(): array
26
    {
27
        return [
28
            ['Air conditioning', null],
29
            ['Balcony', null],
30
            ['Elevator', null],
31
            ['Fire Alarm', null],
32
            ['First Floor Entry', null],
33
            ['High Impact Doors', null],
34
            ['Patio', null],
35
            ['Secure parking', '<i class="fas fa-parking"></i>'],
36
        ];
37
    }
38
}
39