ClassPropertyProcessor::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 2
b 0
f 0
nc 2
nop 3
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 *  This file is part of the Micro framework package.
7
 *
8
 *  (c) Stanislau Komar <[email protected]>
9
 *
10
 *  For the full copyright and license information, please view the LICENSE
11
 *  file that was distributed with this source code.
12
 */
13
14
namespace Micro\Library\DTO\Preparation\Processor;
15
16
use Micro\Library\DTO\ClassDef\ClassDefinition;
17
use Micro\Library\DTO\ClassDef\PropertyDefinition;
18
use Micro\Library\DTO\Preparation\PreparationProcessorInterface;
19
use Micro\Library\DTO\Preparation\Processor\Property\PropertyProcessorInterface;
20
21
class ClassPropertyProcessor implements PreparationProcessorInterface
22
{
23
    /**
24
     * @param iterable<PropertyProcessorInterface> $propertyProcessorCollection
25
     */
26 6
    public function __construct(private iterable $propertyProcessorCollection)
27
    {
28 6
    }
29
30 3
    public function process(array $classDef, ClassDefinition $classDefinition, array $classList): void
31
    {
32 3
        foreach ($classDef[self::SECTION_PROPERTIES] as $property) {
33 3
            $this->processProperty($classDefinition, $property, $classList);
34
        }
35
    }
36
37
    /**
38
     * @param ClassDefinition      $classDefinition
39
     * @param array<string, mixed> $propertyData
40
     * @param array<string>        $classList
41
     *
42
     * @return void
43
     */
44 3
    protected function processProperty(ClassDefinition $classDefinition, array $propertyData, array $classList): void
45
    {
46 3
        $property = new PropertyDefinition();
47 3
        $classDefinition->addProperty($property);
48
49 3
        foreach ($this->propertyProcessorCollection as $processor) {
50 3
            $processor->process($property, $classDefinition, $propertyData, $classList);
51
        }
52
    }
53
}
54