FormFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 4
Bugs 0 Features 1
Metric Value
wmc 2
c 4
b 0
f 1
lcom 0
cbo 4
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A getBuilder() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the WPSymfonyForm plugin.
5
 *
6
 * Copyright (c) 2015-2016 LIN3S <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace LIN3S\WPSymfonyForm\Factory;
13
14
use Symfony\Component\Form\Extension\Core\CoreExtension;
15
use Symfony\Component\Form\Extension\Validator\ValidatorExtension;
16
use Symfony\Component\Form\FormFactoryBuilder;
17
use Symfony\Component\Validator\ValidatorBuilder;
18
19
/**
20
 * Form factory final class.
21
 *
22
 * @author Gorka Laucirica <[email protected]>
23
 * @author Beñat Espiña <[email protected]>
24
 */
25
final class FormFactory
26
{
27
    /**
28
     * Creates a form factory with the default configuration.
29
     *
30
     * @return \Symfony\Component\Form\FormFactoryInterface
31
     */
32
    public static function get()
33
    {
34
        return self::getBuilder()->getFormFactory();
35
    }
36
37
    /**
38
     * Creates a form factory builder with the default configuration.
39
     *
40
     * @return FormFactoryBuilder
41
     */
42
    private static function getBuilder()
43
    {
44
        $builder = new FormFactoryBuilder();
45
        $builder->addExtension(new CoreExtension());
46
47
        $validatorBuilder = new ValidatorBuilder();
48
        $builder->addExtension(new ValidatorExtension($validatorBuilder->getValidator()));
49
50
        return $builder;
51
    }
52
}
53