CollectionPropertyResolver   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 34
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B resolve() 0 23 4
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 29.07.2016
6
 * Time: 21:38.
7
 */
8
namespace samsonframework\containercollection;
9
10
use samsonframework\container\configurator\PropertyConfiguratorInterface;
11
use samsonframework\container\metadata\ClassMetadata;
12
use samsonframework\container\resolver\PropertyResolverTrait;
13
14
/**
15
 * Collection property resolver class.
16
 *
17
 * @author Vitaly Iegorov <[email protected]>
18
 */
19
class CollectionPropertyResolver extends AbstractCollectionResolver implements CollectionResolverInterface
20
{
21
    use PropertyResolverTrait;
22
23
    /** Collection property key */
24
    const KEY = 'properties';
25
26
    /**
27
     * {@inheritDoc}
28
     */
29 1
    public function resolve(array $configurationArray, ClassMetadata $classMetadata)
30
    {
31
        // Iterate collection
32 1
        if (array_key_exists(self::KEY, $configurationArray)) {
33 1
            $reflectionClass = new \ReflectionClass($classMetadata->className);
34
35
            // Iterate configured properties
36 1
            foreach ($configurationArray[self::KEY] as $propertyName => $propertyDataArray) {
37 1
                $propertyMetadata = $this->resolvePropertyMetadata(
38 1
                    $reflectionClass->getProperty($propertyName),
39
                    $classMetadata
40
                );
41
42
                // Process attributes
43 1
                foreach ($this->getAttributeConfigurator($propertyDataArray) as $configurator) {
44
                    /** @var PropertyConfiguratorInterface $configurator Parse property metadata */
45 1
                    $configurator->toPropertyMetadata($propertyMetadata);
46
                }
47
            }
48
        }
49
50 1
        return $classMetadata;
51
    }
52
}
53