Completed
Pull Request — master (#49)
by
unknown
01:57
created

LegacyFormHelper::__clone()   A

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
c 1
b 1
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
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\Util;
12
13
/**
14
 * This class was based on LegacyFormHelper in FOSUserBundle:
15
 * https://github.com/FriendsOfSymfony/FOSUserBundle/blob/c533a233b52c1d3843e816a35677561330ddbc74/Util/LegacyFormHelper.php
16
 *
17
 * @internal
18
 *
19
 * @author Gabor Egyed <[email protected]>
20
 * @author Jaik Dean <[email protected]>
21
 */
22
final class LegacyFormHelper
23
{
24
    private static $map = array(
25
        'Symfony\Component\Form\Extension\Core\Type\ChoiceType' => 'choice',
26
    );
27
28
    public static function getType($class)
29
    {
30
        if (!self::isLegacy()) {
31
            return $class;
32
        }
33
34
        if (!isset(self::$map[$class])) {
35
            throw new \InvalidArgumentException(sprintf('Form type with class "%s" can not be found. Please check for typos or add it to the map in LegacyFormHelper', $class));
36
        }
37
38
        return self::$map[$class];
39
    }
40
41
    public static function isLegacy()
42
    {
43
        return !method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix');
44
    }
45
46
    private function __construct()
47
    {
48
    }
49
50
    private function __clone()
51
    {
52
    }
53
}
54