LoadSemester   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 11
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getOrder() 0 3 1
A load() 0 11 2
1
<?php
2
3
/*
4
 * This file is part of the thealternativezurich/feedback project.
5
 *
6
 * (c) Florian Moser <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace App\DataFixtures;
13
14
use App\DataFixtures\Base\BaseFixture;
15
use App\Entity\Semester;
16
use Doctrine\Persistence\ObjectManager;
17
18
class LoadSemester extends BaseFixture
19
{
20
    public const ORDER = 1;
21
22
    /**
23
     * Load data fixtures with the passed EntityManager.
24
     */
25
    public function load(ObjectManager $manager)
26
    {
27
        $semesters = ['HS 2018', 'FS 2019'];
28
        $count = 0;
29
        foreach ($semesters as $semesterName) {
30
            $semester = new Semester();
31
            $semester->setName($semesterName);
32
            $semester->setCreationDate((new \DateTime('today'))->modify('+'.$count++.' day'));
33
            $manager->persist($semester);
34
        }
35
        $manager->flush();
36
    }
37
38
    /**
39
     * Get the order of this fixture.
40
     *
41
     * @return int
42
     */
43
    public function getOrder()
44
    {
45
        return static::ORDER;
46
    }
47
}
48