Completed
Push — develop ( 20cffe...ad5ee4 )
by Florian
03:42
created

LegacyFormHelper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
namespace Braincrafted\Bundle\BootstrapBundle\Util;
3
4
/**
5
 * Special thanks to the authors of FOSUserBundle on which this Util is based on.
6
 *
7
 * @internal
8
 *
9
 * @author Adrian Gorny <[email protected]>
10
 */
11
final class LegacyFormHelper
12
{
13
    private static $map = array(
14
        'form' => 'Symfony\Component\Form\Extension\Core\Type\FormType',
15
        'email' => 'Symfony\Component\Form\Extension\Core\Type\EmailType',
16
        'text' => 'Symfony\Component\Form\Extension\Core\Type\TextType',
17
        'submit' => 'Symfony\Component\Form\Extension\Core\Type\SubmitType',
18
        'button' => 'Symfony\Component\Form\Extension\Core\Type\ButtonType',
19
        'collection' => 'Symfony\Component\Form\Extension\Core\Type\CollectionType'
20
    );
21
22
    public static function getType($class)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
23
    {
24
        if (self::isLegacy()) {
25
            return $class;
26
        }
27
28
        if (!isset(self::$map[$class])) {
29
            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));
30
        }
31
32
        return self::$map[$class];
33
    }
34
35
    public static function isLegacy()
36
    {
37
        return !method_exists('Symfony\Component\Form\AbstractType', 'getBlockPrefix');
38
    }
39
40
    private function __construct()
41
    {
42
    }
43
44
    private function __clone()
45
    {
46
    }
47
}
48