Completed
Push — master ( d4e15c...f561d0 )
by Pavel
18:12 queued 10s
created

DependencyInjectionExtension   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 7
c 1
b 1
f 0
dl 0
loc 24
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A hasType() 0 3 1
A getType() 0 7 2
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
}