Events   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B load() 0 34 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\Event;
24
use AppBundle\Entity\ObjectType;
25
use DateTime;
26
use Doctrine\Common\DataFixtures\AbstractFixture;
27
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
28
use Doctrine\Common\Persistence\ObjectManager;
29
30
/**
31
 * Load mine data class.
32
 *
33
 * @category  Eco4 App
34
 *
35
 * @author    Francois-Xavier Soubirou <[email protected]>
36
 * @copyright 2016 Francois-Xavier Soubirou
37
 * @license   http://www.gnu.org/licenses/   GPLv3
38
 *
39
 * @link      https://www.eco4.io
40
 */
41
class Events extends AbstractFixture implements OrderedFixtureInterface
42
{
43
    /**
44
     * Load data fixtures with the passed EntityManager.
45
     *
46
     * @param ObjectManager $manager The entity manager
47
     *
48
     *
49
     * @codeCoverageIgnore
50
     */
51
    public function load(ObjectManager $manager)
52
    {
53
        $refDate = new DateTime();
54
        $refDate->setDate(2016, 8, 2)->setTime(0, 0, 1);
55
        $dataArray = array(
56
            array(
57
                'category' => Event::CAT_UPGRADE,
58
                'type' => ObjectType::MINE,
59
                'user' => 'user6-user',
60
                'datetime' => $refDate,
61
                'status' => Event::STATUS_PLANNED,
62
            ),
63
            array(
64
                'category' => Event::CAT_UPGRADE,
65
                'type' => ObjectType::MINE,
66
                'user' => 'user7-user',
67
                'datetime' => $refDate,
68
                'status' => Event::STATUS_CANCELED,
69
            ),
70
        );
71
        $objectList = array();
72
73
        foreach ($dataArray as $i => $data) {
74
            $objectList[$i] = new Event();
75
            $objectList[$i]->setCategory($data['category']);
76
            $objectList[$i]->setObjectType($data['type']);
77
            $objectList[$i]->setUser($this->getReference($data['user']));
78
            $objectList[$i]->setEventDatetime($data['datetime']);
79
            $objectList[$i]->setStatus($data['status']);
80
81
            $manager->persist($objectList[$i]);
82
        }
83
        $manager->flush();
84
    }
85
86
    /**
87
     * Get the order of this fixture.
88
     *
89
     * @return int
90
     *
91
     * @codeCoverageIgnore
92
     */
93
    public function getOrder()
94
    {
95
        return 30;
96
    }
97
}
98