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

CollectionParameterResolver::resolve()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 18
Code Lines 7

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 18
loc 18
ccs 7
cts 7
cp 1
rs 9.2
c 1
b 0
f 1
cc 4
eloc 7
nc 2
nop 2
crap 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\container\collection;
9
10
use samsonframework\container\configurator\ParameterConfiguratorInterface;
11
use samsonframework\container\metadata\ParameterMetadata;
12
13
/**
14
 * Collection parameter resolver class.
15
 * @author Vitaly Iegorov <[email protected]>
16
 */
17 View Code Duplication
class CollectionParameterResolver extends AbstractCollectionResolver implements CollectionParameterResolverInterface
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...
18
{
19
    /** Collection parameter key */
20
    const KEY = 'arguments';
21
22
    /**
23
     * {@inheritDoc}
24
     */
25 1
    public function resolve(array $parameterDataArray, ParameterMetadata $parameterMetadata)
26
    {
27
        // Iterate collection
28 1
        if (array_key_exists('@attributes', $parameterDataArray)) {
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, $parameterDataArray['@attributes'])) {
33
                    /** @var ParameterConfiguratorInterface $configurator Create instance */
34 1
                    $configurator = new $collectionConfigurator($parameterDataArray['@attributes'][$key]);
35
                    // Fill in class metadata
36 1
                    $configurator->toParameterMetadata($parameterMetadata);
37
                }
38
            }
39
        }
40
41 1
        return $parameterMetadata;
42
    }
43
}
44