Completed
Push — Recipes ( 630f49...c8afb0 )
by Laurent
12:15 queued 03:48
created

LoadArticleData   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 144
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 144
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
B load() 0 123 2
A getDependencies() 0 7 1
A getGroups() 0 4 1
1
<?php
2
/**
3
 * LoadArticleData Data of articles from GLSR application.
4
 *
5
 * PHP Version 7
6
 *
7
 * @author    Quétier Laurent <[email protected]>
8
 * @copyright 2014 Dev-Int GLSR
9
 * @license   http://opensource.org/licenses/gpl-license.php GNU Public License
10
 *
11
 * @version GIT: <git_id>
12
 *
13
 * @see https://github.com/Dev-Int/glsr
14
 */
15
16
namespace App\DataFixtures;
17
18
use App\Entity\Settings\Article;
19
use App\Entity\Settings\Diverse\Material;
20
use Doctrine\Common\Persistence\ObjectManager;
21
use Doctrine\Bundle\FixturesBundle\Fixture;
22
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
23
use Doctrine\Bundle\FixturesBundle\FixtureGroupInterface;
24
25
/**
26
 * Load Article Data.
27
 *
28
 * @category DataFixtures
29
 */
30
class LoadArticleData extends Fixture implements DependentFixtureInterface, FixtureGroupInterface
31
{
32
    /**
33
     * Load data fixtures with the passed EntityManager.
34
     *
35
     * @param ObjectManager $manager
36
     */
37
    public function load(ObjectManager $manager)
38
    {
39
        // References of suppliers
40
        $davigel = $this->getReference('supplier1');
41
        $davifrais = $this->getReference('supplier2');
42
        $davisec = $this->getReference('supplier3');
43
        $loireBoissons = $this->getReference('supplier4');
44
        // References of logistics families
45
        $surgele = $this->getReference('family-log3');
0 ignored issues
show
Unused Code introduced by
$surgele is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
46
        $frais = $this->getReference('family-log4');
47
        $sec = $this->getReference('family-log5');
48
        $boissons = $this->getReference('family-log6');
0 ignored issues
show
Unused Code introduced by
$boissons is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
49
        $fruitLegumesSurgele = $this->getReference('family-log7');
0 ignored issues
show
Unused Code introduced by
$fruitLegumesSurgele is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
50
        $patisseriesSurgele = $this->getReference('family-log8');
0 ignored issues
show
Unused Code introduced by
$patisseriesSurgele is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
51
        $viandeSurgele = $this->getReference('family-log9');
52
        $fruitLegumesFrais = $this->getReference('family-log10');
53
        $patisseriesFrais = $this->getReference('family-log11');
0 ignored issues
show
Unused Code introduced by
$patisseriesFrais is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
54
        $viandeFrais = $this->getReference('family-log12');
0 ignored issues
show
Unused Code introduced by
$viandeFrais is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
55
        $fruitLegumesSec = $this->getReference('family-log13');
0 ignored issues
show
Unused Code introduced by
$fruitLegumesSec is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
56
        $patisseriesSec = $this->getReference('family-log14');
0 ignored issues
show
Unused Code introduced by
$patisseriesSec is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
57
        $bieres = $this->getReference('family-log15');
0 ignored issues
show
Unused Code introduced by
$bieres is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
58
        $vins = $this->getReference('family-log16');
59
        // Storage area references
60
        $zoneSurgele = $this->getReference('zoneStorage1');
61
        $zoneFrais = $this->getReference('zoneStorage2');
62
        $zoneSec = $this->getReference('zoneStorage3');
63
        $zoneBoisson = $this->getReference('zoneStorage4');
64
        // Unit References
65
        $boite = $this->getReference('unit1');
0 ignored issues
show
Unused Code introduced by
$boite is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
66
        $bouteille = $this->getReference('unit2');
67
        $carton = $this->getReference('unit3');
0 ignored issues
show
Unused Code introduced by
$carton is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
68
        $colis = $this->getReference('unit4');
0 ignored issues
show
Unused Code introduced by
$colis is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
69
        $kilogramme = $this->getReference('unit5');
70
        $litre = $this->getReference('unit6');
0 ignored issues
show
Unused Code introduced by
$litre is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
71
        $piece = $this->getReference('unit7');
72
        // VAT references
73
        $tvaReduit = $this->getReference('tva1');
74
        $tvaMoyen = $this->getReference('tva2');
0 ignored issues
show
Unused Code introduced by
$tvaMoyen is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
75
        $tvaLuxe = $this->getReference('tva3');
0 ignored issues
show
Unused Code introduced by
$tvaLuxe is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
76
77
        // Articles datas
78
        $datas = [
79
            ['name' => 'Salade', 'supplier' => $davifrais,
80
            'familyLog' => $fruitLegumesFrais, 'zoneStorage' => $zoneFrais,
81
            'unitStorage' => $piece, 'unitWorking' => $kilogramme, 'price' => 2.99,
82
            'packaging' => 12, 'tva' => $tvaReduit, 'minStock' => 2, ],
83
            ['name' => 'Bavette 150gr', 'supplier' => $davigel,
84
            'familyLog' => $viandeSurgele, 'zoneStorage' => $zoneSurgele,
85
            'unitStorage' => $piece, 'unitWorking' => $piece, 'price' => 2.99,
86
            'packaging' => 28, 'tva' => $tvaReduit, 'minStock' => 2, ],
87
            ['name' => 'Baguettine', 'supplier' => $davigel,
88
            'familyLog' => $viandeSurgele, 'zoneStorage' => $zoneSurgele,
89
            'unitStorage' => $piece, 'unitWorking' => $piece, 'price' => 15.2,
90
            'packaging' => 90, 'tva' => $tvaReduit, 'minStock' => 20, ],
91
            ['name' => 'Steack haché 20%MG 120g', 'supplier' => $davigel,
92
            'familyLog' => $viandeSurgele, 'zoneStorage' => $zoneSurgele,
93
            'unitStorage' => $piece, 'unitWorking' => $piece, 'price' => 1.22,
94
            'packaging' => 50, 'tva' => $tvaReduit, 'minStock' => 12, ],
95
            ['name' => 'Ananas poche 2.3 KG', 'supplier' => $davisec,
96
            'familyLog' => $sec, 'zoneStorage' => $zoneSec,
97
            'unitStorage' => $piece, 'unitWorking' => $kilogramme, 'price' => 4.05,
98
            'packaging' => 4, 'tva' => $tvaReduit, 'minStock' => 3, ],
99
            ['name' => 'Appareil Champigons 2 KG', 'supplier' => $davifrais,
100
            'familyLog' => $frais, 'zoneStorage' => $zoneFrais,
101
            'unitStorage' => $piece, 'unitWorking' => $kilogramme, 'price' => 6.39,
102
            'packaging' => 4, 'tva' => $tvaReduit, 'minStock' => 2, ],
103
            ['name' => 'Bacon tranche Barq 88G', 'supplier' => $davifrais,
104
            'familyLog' => $frais, 'zoneStorage' => $zoneFrais,
105
            'unitStorage' => $piece, 'unitWorking' => $kilogramme, 'price' => 0.75,
106
            'packaging' => 6, 'tva' => $tvaReduit, 'minStock' => 2, ],
107
            ['name' => 'Beurre doux 8Gx125', 'supplier' => $davifrais,
108
            'familyLog' => $frais, 'zoneStorage' => $zoneFrais,
109
            'unitStorage' => $kilogramme, 'unitWorking' => $piece, 'price' => 6.83,
110
            'packaging' => 1, 'tva' => $tvaReduit, 'minStock' => 0.5, ],
111
            ['name' => 'Boule pour oeuf neige', 'supplier' => $davifrais,
112
            'familyLog' => $frais, 'zoneStorage' => $zoneFrais,
113
            'unitStorage' => $piece, 'unitWorking' => $piece, 'price' => 1.75,
114
            'packaging' => 6, 'tva' => $tvaReduit, 'minStock' => 2, ],
115
            ['name' => 'Champignons émincé 500G', 'supplier' => $davifrais,
116
            'familyLog' => $fruitLegumesFrais, 'zoneStorage' => $zoneFrais,
117
            'unitStorage' => $kilogramme, 'unitWorking' => $kilogramme,
118
            'price' => 3.17, 'packaging' => 3.5, 'tva' => $tvaReduit,
119
            'minStock' => 1, ],
120
            ['name' => 'Chorizo prétr. 500G', 'supplier' => $davifrais,
121
            'familyLog' => $fruitLegumesFrais, 'zoneStorage' => $zoneFrais,
122
            'unitStorage' => $kilogramme, 'unitWorking' => $kilogramme,
123
            'price' => 5.11, 'packaging' => 6, 'tva' => $tvaReduit, 'minStock' => 1, ],
124
            ['name' => 'V.RG Bourgueil 75cl', 'supplier' => $loireBoissons,
125
            'familyLog' => $vins, 'zoneStorage' => $zoneBoisson,
126
            'unitStorage' => $bouteille, 'unitWorking' => $bouteille,
127
            'price' => 5.11, 'packaging' => 6, 'tva' => $tvaReduit, 'minStock' => 3, ],
128
        ];
129
130
        foreach ($datas as $key => $data) {
131
            $article = new Article();
132
            $article->setName($data['name'])
133
                ->setSupplier($data['supplier'])
134
                ->setFamilyLog($data['familyLog'])
135
                ->addZoneStorage($data['zoneStorage'])
136
                ->setUnitStorage($data['unitStorage'])
137
                ->setUnitWorking($data['unitWorking'])
138
                ->setPrice($data['price'])
139
                ->setPackaging($data['packaging'])
140
                ->setTva($data['tva'])
141
                ->setMinStock($data['minStock']);
142
143
            $manager->persist($article);
144
            $order = $key + 1;
145
            $this->addReference('article'.$order, $article);
146
147
            $material = new Material();
148
            $material->setName($data['name'])
149
                ->setUnitWorking($data['unitWorking'])
150
                ->addArticle($this->getReference('article'.$order))
151
                ->setMultiple(0)
0 ignored issues
show
Documentation introduced by
0 is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
152
                ->setActive(1);
0 ignored issues
show
Documentation introduced by
1 is of type integer, but the function expects a boolean.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
153
154
            $manager->persist($material);
155
            $this->addReference('material'.$order, $material);
156
        }
157
158
        $manager->flush();
159
    }
160
161
    public function getDependencies()
162
    {
163
        return [
164
            LoadDiverseData::class,
165
            LoadSupplierData::class,
166
        ];
167
    }
168
169
    public static function getGroups(): array
170
    {
171
        return ['settingsGroup'];
172
    }
173
}
174