Completed
Push — master ( 46961e...b2acd3 )
by Axel
04:17 queued 01:11
created

LoadProjectData::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 20
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 20
ccs 18
cts 18
cp 1
rs 9.4285
cc 2
eloc 16
nc 2
nop 1
crap 2
1
<?php
2
namespace Developtech\AgilityBundle\DataFixtures\ORM;
3
4
use Doctrine\Common\Persistence\ObjectManager;
5
use Doctrine\Common\DataFixtures\AbstractFixture;
6
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
use Symfony\Component\DependencyInjection\ContainerInterface;
8
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9
10
use Developtech\AgilityBundle\Entity\Project;
11
12
class LoadProjectData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface {
13
    /** @var ContainerInterface */
14
    private $container;
15
    /**
16
     * @param ContainerInterface $container
17
     */
18 1
    public function setContainer(ContainerInterface $container = null) {
19 1
        $this->container = $container;
20 1
    }
21
    /**
22
     * @param ObjectManager $manager
23
     */
24 1
    public function load(ObjectManager $manager) {
25 1
        $data = include('fixtures/projects.php');
26 1
        foreach ($data as $projectData)
27
        {
28
            $project =
29 1
                (new Project())
30 1
                ->setId($projectData['id'])
31 1
                ->setName($projectData['name'])
32 1
                ->setSlug($projectData['slug'])
33 1
                ->setDescription($projectData['description'])
34 1
                ->setBetaTestStatus($projectData['beta_test_status'])
35 1
                ->setNbBetaTesters($projectData['nb_beta_testers'])
36 1
                ->setCreatedAt(new \DateTime($projectData['created_at']))
37 1
            ;
38 1
            $manager->persist($project);
39 1
            $this->addReference("project-{$project->getId()}", $project);
40 1
        }
41 1
        $manager->flush();
42 1
        $manager->clear(Project::class);
43 1
    }
44
    /**
45
     * @return int
46
     */
47 1
    public function getOrder() {
48 1
        return 1;
49
    }
50
}
51