RestFormFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
ccs 4
cts 4
cp 1
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Pgs\RestfonyBundle\Form\Factory;
4
5
use Symfony\Component\Form\FormFactoryInterface;
6
use Symfony\Component\Form\FormInterface;
7
use Symfony\Component\Form\FormTypeInterface;
8
9
/**
10
 * @author Michał Sikora
11
 */
12
class RestFormFactory
13
{
14
    /**
15
     * @var FormFactoryInterface
16
     */
17
    private $formFactory;
18
19
    /**
20
     * @var FormTypeInterface
21
     */
22
    private $formType;
23
24
    /**
25
     * @param FormFactoryInterface $formFactory
26
     * @param FormTypeInterface    $formType
27
     */
28 1
    public function __construct(FormFactoryInterface $formFactory, FormTypeInterface $formType)
29
    {
30 1
        $this->formFactory = $formFactory;
31 1
        $this->formType = $formType;
32 1
    }
33
34
    /**
35
     * @param object $data
36
     * @param array  $options
37
     *
38
     * @return FormInterface
39
     */
40 1
    public function create($data = null, array $options = array())
41
    {
42 1
        $formTypeClass = get_class($this->formType);
43 1
        return $this->formFactory->create($formTypeClass, $data, $options);
44
    }
45
}
46