LoadSettings::load()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace App\DataFixtures;
4
5
use App\Entity\Guild;
6
use App\Entity\Setting;
7
use Doctrine\Common\Persistence\ObjectManager;
8
use Doctrine\Bundle\FixturesBundle\Fixture;
9
10
/**
11
 * Class LoadSettings
12
 * @package App\DataFixtures
13
 */
14
class LoadSettings extends Fixture
15
{
16
    /**
17
     * @param ObjectManager $manager
18
     */
19
    public function load(ObjectManager $manager)
20
    {
21
        $this->loadSettings($manager);
22
        $this->loadGuild($manager);
23
    }
24
25
    /**
26
     * @return array
27
     */
28
    private function getData(): array
29
    {
30
        return [
31
            ['SWGOH', 'swgoh', 'https://swgoh.gg', '/u', '/g']
32
        ];
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    private function getGuildData(): array
39
    {
40
        return [
41
            ['Tears of Wrath', '20375', 'tears-of-wrath']
42
        ];
43
    }
44
45
    /**
46
     * @param ObjectManager $manager
47
     */
48
    private function loadSettings(ObjectManager $manager): void
0 ignored issues
show
Coding Style Best Practice introduced by
Please use __construct() instead of a PHP4-style constructor that is named after the class.
Loading history...
49
    {
50
        foreach ($this->getData() as [$title, $code, $api, $user, $guild]) {
51
            $setting = new Setting();
52
            $setting->setTitle($title)
0 ignored issues
show
Bug introduced by
The variable $title does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
53
                ->setCode($code)
0 ignored issues
show
Bug introduced by
The variable $code does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
54
                ->setApi($api)
0 ignored issues
show
Bug introduced by
The variable $api does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
55
                ->setUserSuffix($user)
0 ignored issues
show
Bug introduced by
The variable $user does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
56
                ->setGuildSuffix($guild);
0 ignored issues
show
Bug introduced by
The variable $guild does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
57
58
            $manager->persist($setting);
59
            $this->addReference(sprintf("%s-api", $title), $setting);
60
        }
61
62
        $manager->flush();
63
    }
64
65
    /**
66
     * @param ObjectManager $manager
67
     */
68
    private function loadGuild(ObjectManager $manager): void
69
    {
70
        foreach ($this->getGuildData() as [$title, $uuid, $code]) {
71
            $setting = new Guild();
72
            $setting->setUuid($title)
0 ignored issues
show
Bug introduced by
The variable $title does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
73
                ->setUuid($uuid)
0 ignored issues
show
Bug introduced by
The variable $uuid does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
74
                ->setCode($code)
0 ignored issues
show
Bug introduced by
The variable $code does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
75
                ->setTitle($title);
76
77
            $manager->persist($setting);
78
            $this->addReference(sprintf("%s-guild", $code), $setting);
79
        }
80
81
        $manager->flush();
82
    }
83
}
84