Completed
Push — master ( 8cc443...0d7c83 )
by Vitaly
02:51
created

CollectionClassResolver::resolveArrayKeys()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 2
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 2
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
 * Collection class resolver class.
15
 *
16
 * @author Vitaly Iegorov <[email protected]>
17
 */
18 View Code Duplication
class CollectionClassResolver extends AbstractCollectionResolver implements CollectionResolverInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
19
{
20
    /** Collection class key */
21
    const KEY = 'instance';
22
23
    /**
24
     * {@inheritDoc}
25
     */
26 1
    public function resolve(array $classDataArray, ClassMetadata $classMetadata)
27
    {
28
        // Iterate collection
29
        // TODO Move this code into abstract class because this code are identical for three classes only with different configurator method name
30 1
        if (array_key_exists('@attributes', $classDataArray)) {
31
            // Iterate collection attribute configurators
32 1
            foreach ($this->collectionConfigurators as $key => $collectionConfigurator) {
33
                // If this is supported collection configurator
34 1
                if (array_key_exists($key, $classDataArray['@attributes'])) {
35
                    /** @var ClassConfiguratorInterface $configurator Create instance */
36 1
                    $configurator = new $collectionConfigurator($classDataArray['@attributes'][$key]);
37
                    // Fill in class metadata
38 1
                    $configurator->toClassMetadata($classMetadata);
39
                }
40
            }
41
        }
42
43 1
        return $classMetadata;
44
    }
45
}
46