Completed
Push — master ( 29a4f7...8a3bcf )
by Artem
04:10
created

AbstractEnumExtension::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
rs 9.4286
cc 3
eloc 4
nc 3
nop 1
1
<?php
2
/*
3
 * This file is part of the FreshDoctrineEnumBundle
4
 *
5
 * (c) Artem Genvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Fresh\DoctrineEnumBundle\Twig\Extension;
12
13
use Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType;
14
15
/**
16
 * BaseEnumExtension
17
 *
18
 * @author Artem Genvald <[email protected]>
19
 */
20
abstract class AbstractEnumExtension extends \Twig_Extension
21
{
22
    /**
23
     * @var AbstractEnumType[] $registeredEnumTypes Array of registered ENUM types
24
     */
25
    protected $registeredEnumTypes = [];
26
27
    /**
28
     * Constructor
29
     *
30
     * @param array $registeredTypes Array of registered ENUM types
31
     */
32
    public function __construct(array $registeredTypes)
33
    {
34
        foreach ($registeredTypes as $type => $details) {
35
            if (is_subclass_of($details['class'], '\Fresh\DoctrineEnumBundle\DBAL\Types\AbstractEnumType')) {
36
                $this->registeredEnumTypes[$type] = $details['class'];
37
            }
38
        }
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    abstract public function getName();
45
}
46