Container::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace IgnoreFiles;
4
5
use Symfony\Component\Config\FileLocator;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
8
9
class Container
10
{
11
    const SERVICES_FILE = 'services.xml';
12
    const CONFIG_PATH = '/../../config/';
13
    /**
14
     * @var ContainerBuilder
15
     */
16
    private $container;
17
18
    /**
19
     * Container constructor.
20
     */
21
    public function __construct()
22
    {
23
        $this->container = new ContainerBuilder();
24
        $this->getConfigServices();
25
    }
26
27
    private function getConfigServices()
28
    {
29
        $loader = new XmlFileLoader($this->container, new FileLocator(__DIR__.self::CONFIG_PATH));
30
        $loader->load(self::SERVICES_FILE);
31
    }
32
33
    /**
34
     * @param string $serviceName
35
     *
36
     * @return object
37
     */
38
    public function get($serviceName)
39
    {
40
        return $this->container->get($serviceName);
41
    }
42
}
43