Completed
Push — master ( a81a90...8dc74b )
by Valery
04:17
created

OperationFixtures::getOperationData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\DataFixtures;
6
7
use App\Entity\Operation;
8
use Doctrine\Bundle\FixturesBundle\Fixture;
9
use Doctrine\Common\Persistence\ObjectManager;
10
11
class OperationFixtures extends Fixture
12
{
13
    public function load(ObjectManager $manager): void
14
    {
15
        foreach ($this->getOperationData() as [$slug, $name]) {
16
            $operation = new Operation();
17
            $operation->setName($name);
18
            $operation->setSlug($slug);
19
            $manager->persist($operation);
20
            $this->addReference($name, $operation);
21
        }
22
        $manager->flush();
23
    }
24
25
    private function getOperationData(): array
26
    {
27
        return [
28
            // $operationData = [$slug, $name];
29
            ['rent', 'Rent'],
30
            ['sale', 'Sale'],
31
        ];
32
    }
33
}
34