PostConfigureReflectionSetProperties   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 5
c 2
b 0
f 0
dl 0
loc 31
ccs 7
cts 7
cp 1
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A postConfigure() 0 8 3
A __construct() 0 16 1
1
<?php
2
3
namespace Bdf\Form\Attribute\Processor;
4
5
use Bdf\Form\Aggregate\FormInterface;
6
use Bdf\Form\Attribute\AttributeForm;
7
use ReflectionProperty;
8
9
/**
10
 * Fill the form properties using reflection
11
 */
12
final class PostConfigureReflectionSetProperties implements PostConfigureInterface
13
{
14 52
    public function __construct(
15
        /**
16
         * Properties which store form elements
17
         * The key is the element name, and value is the reflection property
18
         *
19
         * @var array<non-empty-string, ReflectionProperty>
20
         */
21
        private array $elementProperties,
22
        /**
23
         * Properties which store form buttons
24
         * The key is the button name, and value is the reflection property
25
         *
26
         * @var array<non-empty-string, ReflectionProperty>
27
         */
28
        private array $buttonProperties,
29
    ) {
30 52
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35 52
    public function postConfigure(AttributeForm $form, FormInterface $inner): void
36
    {
37 52
        foreach ($this->elementProperties as $name => $reflection) {
38 44
            $reflection->setValue($form, $inner[$name]->element());
39
        }
40
41 52
        foreach ($this->buttonProperties as $name => $reflection) {
42 3
            $reflection->setValue($form, $form->root()->button($name));
43
        }
44
    }
45
}
46