Passed
Push — develop ( 3d1775...ebd477 )
by Mathieu
02:47
created

FormReader::configureFields()   B

Complexity

Conditions 9
Paths 13

Size

Total Lines 59
Code Lines 32

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 32
c 0
b 0
f 0
dl 0
loc 59
rs 8.0555
cc 9
nc 13
nop 3

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace KunicMarko\SonataAnnotationBundle\Reader;
6
7
use Doctrine\Common\Annotations\Reader;
8
use KunicMarko\SonataAnnotationBundle\Annotation\FormField;
9
use ReflectionClass;
10
use Sonata\AdminBundle\Form\FormMapper;
11
12
/**
13
 * Form configuration reader.
14
 *
15
 * @author Marko Kunic <[email protected]>
16
 * @author Mathieu Wambre <[email protected]>
17
 */
18
final class FormReader extends AbstractFieldConfigurationReader
19
{
20
21
    /**
22
     * {@inheritDoc}
23
     */
24
    public function __construct(
25
        Reader $annotationReader
26
    ) {
27
        parent::__construct($annotationReader, FormField::class);
28
    }
29
30
    /**
31
     * Build creation fields configuration.
32
     *
33
     * @param ReflectionClass $class      Entity class.
34
     * @param FormMapper      $formMapper Admin form mapper.
35
     *
36
     * @return void
37
     */
38
    public function configureCreateFields(
39
        ReflectionClass $class,
40
        FormMapper $formMapper
41
    ): void {
42
        $this->configureReaderFields(
43
            $class,
44
            $formMapper,
45
            $this->annotationClass,
46
            FormField::ACTION_CREATE
47
        );
48
    }
49
50
    /**
51
     * Build edit fields configuration.
52
     *
53
     * @param ReflectionClass $class      Entity class.
54
     * @param FormMapper      $formMapper Admin form mapper.
55
     *
56
     * @return void
57
     */
58
    public function configureEditFields(
59
        ReflectionClass $class,
60
        FormMapper $formMapper
61
    ): void {
62
        $this->configureReaderFields(
63
            $class,
64
            $formMapper,
65
            $this->annotationClass,
66
            FormField::ACTION_EDIT
67
        );
68
    }
69
70
}
71