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

LegacyFormHelper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 37
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getType() 0 12 3
A isLegacy() 0 4 1
A __construct() 0 3 1
A __clone() 0 3 1
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