Fixture::get()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace AppBundle\DataFixtures\ORM;
4
5
use Doctrine\Common\DataFixtures\FixtureInterface;
6
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
7
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
8
use Symfony\Component\DependencyInjection\ContainerInterface;
9
10
abstract class Fixture implements FixtureInterface, OrderedFixtureInterface, ContainerAwareInterface
11
{
12
    /**
13
     * @var ContainerInterface
14
     */
15
    private $container;
16
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function getOrder()
21
    {
22
        return 1;
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28
    public function get($id)
29
    {
30
        if (null === $this->container) {
31
            throw new \RuntimeException('Container not injected in fixture.');
32
        }
33
34
        return $this->container->get($id);
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public function setContainer(ContainerInterface $container = null)
41
    {
42
        $this->container = $container;
43
    }
44
}
45