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

CollectionParameterResolver   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
lcom 1
cbo 2
dl 27
loc 27
ccs 7
cts 7
cp 1
rs 10
c 1
b 0
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolve() 18 18 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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