Completed
Push — Recipes ( c1a0bd...9ec83f )
by Laurent
24:17
created

LoadArticleData   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 145
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B load() 0 127 2
A getOrder() 0 4 1
1
<?php
2
/**
3
 * LoadArticleData Données de l'application GLSR.
4
 *
5
 * PHP Version 5
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
 * @link https://github.com/Dev-Int/glsr
14
 */
15
namespace AppBundle\DataFixtures\ORM;
16
17
use Doctrine\Common\DataFixtures\AbstractFixture;
18
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
19
use Doctrine\Common\Persistence\ObjectManager;
20
21
use libphonenumber\PhoneNumber;
22
use AppBundle\Entity\Settings\Article;
23
use AppBundle\Entity\Settings\Diverse\Material;
24
25
/**
26
 * Load Article Data.
27
 *
28
 * @category DataFixtures
29
 */
30
31
class LoadArticleData extends AbstractFixture implements OrderedFixtureInterface
32
{
33
    /**
34
     * Load data fixtures with the passed EntityManager.
35
     *
36
     * @param ObjectManager $manager
37
     */
38
    public function load(ObjectManager $manager)
39
    {
40
        // Références des fournisseurs
41
        $davigel = $this->getReference('supplier1');
42
        $davifrais = $this->getReference('supplier2');
43
        $davisec = $this->getReference('supplier3');
44
        $loireBoissons = $this->getReference('supplier4');
45
        // Références des catégories
46
        $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...
47
        $frais = $this->getReference('family-log4');
48
        $sec = $this->getReference('family-log5');
49
        $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...
50
        $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...
51
        $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...
52
        $viandeSurgele = $this->getReference('family-log9');
53
        $fruitLegumesFrais = $this->getReference('family-log10');
54
        $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...
55
        $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...
56
        $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...
57
        $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...
58
        $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...
59
        $vins = $this->getReference('family-log16');
60
        // Références des zones de stockage
61
        $zoneSurgele = $this->getReference('zoneStorage1');
62
        $zoneFrais = $this->getReference('zoneStorage2');
63
        $zoneSec = $this->getReference('zoneStorage3');
64
        $zoneBoisson = $this->getReference('zoneStorage4');
65
        // Références des unités
66
        $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...
67
        $bouteille = $this->getReference('unit2');
68
        $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...
69
        $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...
70
        $kilogramme = $this->getReference('unit5');
71
        $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...
72
        $piece = $this->getReference('unit7');
73
        // Références des TVA
74
        $tvaReduit = $this->getReference('tva1');
75
        $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...
76
        $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...
77
        // Datas des articles
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
        // INSERT INTO `article` (`id`, `name`, `supplier_id`, `familylog_id`, `subfamilylog_id`, `unitstorage_id`, `quantity`, `unit_fact`, `price`, `minima`, `zonestorage_id`, `tva_id`, `is_active`) VALUES
130
        // (8, 'CREME ANGLAISE 1L', 5, 1, 4, 2, '0.000', '6.000', '1.500', '2.000', 1, 1, 1),
131
        // (9, 'CREME LEGERE UHT 12%', 5, 1, 4, 2, '0.000', '6.000', '2.440', '3.000', 1, 1, 1),
132
        // (10, 'CREME BOMBE UHT 10%', 5, 1, 4, 3, '0.000', '6.000', '5.960', '3.000', 1, 1, 1),
133
        // (11, 'F.BRIE 50%MG 2.7KG', 5, 1, 4, 1, '0.000', '2.700', '4.830', '1.000', 1, 1, 1);
134
135
        foreach ($datas as $key => $data) {
136
            $article = new Article();
137
            $article->setName($data['name'])
138
                ->setSupplier($data['supplier'])
139
                ->setFamilyLog($data['familyLog'])
140
                ->addZoneStorage($data['zoneStorage'])
141
                ->setUnitStorage($data['unitStorage'])
142
                ->setUnitWorking($data['unitWorking'])
143
                ->setPrice($data['price'])
144
                ->setPackaging($data['packaging'])
145
                ->setTva($data['tva'])
146
                ->setMinStock($data['minStock']);
147
148
            $manager->persist($article);
149
            $order = $key + 1;
150
            $this->addReference('article' . $order, $article);
151
152
            $material = new Material();
153
            $material->setName($data['name'])
154
                ->setUnitWorking($data['unitWorking'])
155
                ->addArticle($this->getReference('article' . $order))
156
                ->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...
157
                ->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...
158
159
                $manager->persist($material);
160
                $this->addReference('material' . $order, $material);
161
        }
162
163
        $manager->flush();
164
    }
165
166
    /**
167
     * Get the order of this fixture
168
     *
169
     * @return integer
170
     */
171
    public function getOrder()
172
    {
173
        return 6;
174
    }
175
}