Completed
Push — master ( 821e5b...8cc443 )
by Vitaly
24s
created

CollectionClassResolver::getKey()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 2
nc 1
nop 1
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\container\collection;
9
10
use samsonframework\container\configurator\ClassConfiguratorInterface;
11
use samsonframework\container\metadata\ClassMetadata;
12
13
/**
14
 * Array class resolver class.
15
 * @author Vitaly Iegorov <[email protected]>
16
 */
17
class CollectionClassResolver extends AbstractCollectionResolver implements CollectionResolverInterface
18
{
19
    /** Collection class key */
20
    const KEY = 'instance';
21
22
    /**
23
     * {@inheritDoc}
24
     */
25 1
    public function resolve(array $classDataArray, ClassMetadata $classMetadata)
26
    {
27
        // Iterate collection
28 1
        if (array_key_exists('@attributes', $classDataArray)) {
29
            // Iterate collection attribute configurators
30 1
            foreach ($this->collectionConfigurators as $key => $collectionConfigurator) {
31
                // If this is supported collection configurator
32 1
                if (array_key_exists($key, $classDataArray['@attributes'])) {
33
                    /** @var ClassConfiguratorInterface $configurator Create instance */
34 1
                    $configurator = new $collectionConfigurator($classDataArray['@attributes'][$key]);
35
                    // Fill in class metadata
36 1
                    $configurator->toClassMetadata($classMetadata);
37
                }
38
            }
39
        }
40
41 1
        return $classMetadata;
42
    }
43
44
    public function resolveArrayKeys()
45
    {
46
47
    }
48
}
49