Mines   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 127
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B load() 0 105 2
A getOrder() 0 4 1
1
<?php
2
3
/**
4
 * Copyright (c) 2016 Francois-Xavier Soubirou.
5
 *
6
 * This file is part of eco4.
7
 *
8
 * eco4 is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU General Public License as published by
10
 * the Free Software Foundation, either version 3 of the License, or
11
 * (at your option) any later version.
12
 *
13
 * eco4 is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with eco4. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
namespace AppBundle\DataFixtures\ORM;
22
23
use AppBundle\Entity\Mine;
24
use DateTime;
25
use Doctrine\Common\DataFixtures\AbstractFixture;
26
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
27
use Doctrine\Common\Persistence\ObjectManager;
28
29
/**
30
 * Load mine data class.
31
 *
32
 * @category  Eco4 App
33
 *
34
 * @author    Francois-Xavier Soubirou <[email protected]>
35
 * @copyright 2016 Francois-Xavier Soubirou
36
 * @license   http://www.gnu.org/licenses/   GPLv3
37
 *
38
 * @link      https://www.eco4.io
39
 */
40
class Mines extends AbstractFixture implements OrderedFixtureInterface
41
{
42
    /**
43
     * Load data fixtures with the passed EntityManager.
44
     *
45
     * @param ObjectManager $manager The entity manager
46
     *
47
     * @codeCoverageIgnore
48
     */
49
    public function load(ObjectManager $manager)
50
    {
51
        $now = new DateTime();
52
        $refDate = new DateTime();
53
        $refDate->setDate(2016, 8, 1)->setTime(0, 0, 1);
54
        $dataArray = array(
55
            array(
56
                'level' => 1,
57
                'r1' => 10,
58
                'r2' => 0,
59
                'r3' => 0,
60
                'factor' => '100000000',
61
                'lastUpdate' => $refDate,
62
            ),
63
            array(
64
                'level' => 1,
65
                'r1' => 0,
66
                'r2' => 0,
67
                'r3' => 0,
68
                'factor' => '000100000',
69
                'lastUpdate' => $refDate,
70
            ),
71
            array(
72
                'level' => 1,
73
                'r1' => 0,
74
                'r2' => 0,
75
                'r3' => 0,
76
                'factor' => '000000100',
77
                'lastUpdate' => $refDate,
78
            ),
79
            array(
80
                'level' => 1,
81
                'r1' => 0,
82
                'r2' => 0,
83
                'r3' => 0,
84
                'factor' => '050020005',
85
                'lastUpdate' => $refDate,
86
            ),
87
            array(
88
                'level' => 1,
89
                'r1' => 0,
90
                'r2' => 0,
91
                'r3' => 0,
92
                'factor' => '022022022',
93
                'lastUpdate' => $refDate,
94
            ),
95
            array(
96
                'level' => 1,
97
                'r1' => 0,
98
                'r2' => 0,
99
                'r3' => 0,
100
                'factor' => '022022022',
101
                'lastUpdate' => $refDate,
102
            ),
103
            array(
104
                'level' => 1,
105
                'r1' => 0,
106
                'r2' => 0,
107
                'r3' => 0,
108
                'factor' => '022022022',
109
                'lastUpdate' => $refDate,
110
            ),
111
            array(
112
                'level' => 10,
113
                'r1' => 0,
114
                'r2' => 0,
115
                'r3' => 0,
116
                'factor' => '022022022',
117
                'lastUpdate' => $refDate,
118
            ),
119
            array(
120
                'level' => 1,
121
                'r1' => 0,
122
                'r2' => 0,
123
                'r3' => 0,
124
                'factor' => '022022022',
125
                'lastUpdate' => $now,
126
            ),
127
            array(
128
                'level' => 10,
129
                'r1' => 0,
130
                'r2' => 0,
131
                'r3' => 0,
132
                'factor' => '022022022',
133
                'lastUpdate' => $now,
134
            ),
135
        );
136
        $objectList = array();
137
138
        foreach ($dataArray as $i => $data) {
139
            $objectList[$i] = new Mine();
140
            $objectList[$i]->setLevel($data['level']);
141
            $objectList[$i]->setR1($data['r1']);
142
            $objectList[$i]->setR2($data['r2']);
143
            $objectList[$i]->setR3($data['r3']);
144
            $objectList[$i]->setFactor($data['factor']);
145
            $objectList[$i]->setLastUpdate($data['lastUpdate']);
146
147
            $manager->persist($objectList[$i]);
148
            $id = $i + 1;
149
            $ref = 'mine'.$id.'-mine';
150
            $this->addReference($ref, $objectList[$i]);
151
        }
152
        $manager->flush();
153
    }
154
155
    /**
156
     * Get the order of this fixture.
157
     *
158
     * @return int
159
     *
160
     * @codeCoverageIgnore
161
     */
162
    public function getOrder()
163
    {
164
        return 10;
165
    }
166
}
167