FormFactory::getBuilder()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 0
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