DependencyInjectionExtension::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 1
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
4
namespace Pfilsx\DataGrid\Extension\DependencyInjection;
5
6
7
use InvalidArgumentException;
8
use Symfony\Component\DependencyInjection\ContainerInterface;
9
10
class DependencyInjectionExtension
11
{
12
    /**
13
     * @var ContainerInterface
14
     */
15
    private $typeContainer;
16
17
    public function __construct($typeContainer)
18
    {
19
        $this->typeContainer = $typeContainer;
20
    }
21
22
    public function getType($name)
23
    {
24
        if (!$this->typeContainer->has($name)) {
25
            throw new InvalidArgumentException(sprintf('The field type "%s" is not registered in the service container.', $name));
26
        }
27
28
        return $this->typeContainer->get($name);
29
    }
30
31
    public function hasType($name)
32
    {
33
        return $this->typeContainer->has($name);
34
    }
35
}