ArrayValue   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 4
c 2
b 0
f 2
lcom 1
cbo 2
dl 0
loc 35
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toPropertyMetadata() 0 4 1
A toParameterMetadata() 0 4 1
A __construct() 0 7 2
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 27.07.2016
6
 * Time: 1:55.
7
 */
8
namespace samsonframework\containercollection\attribute;
9
10
use samsonframework\container\configurator\ClassConfiguratorInterface;
11
use samsonframework\container\configurator\ParameterConfiguratorInterface;
12
use samsonframework\container\configurator\PropertyConfiguratorInterface;
13
use samsonframework\container\metadata\ClassMetadata;
14
use samsonframework\container\metadata\ParameterMetadata;
15
use samsonframework\container\metadata\PropertyMetadata;
16
17
/**
18
 * Property/parameter array value attribute configurator class.
19
 *
20
 * @author Vitaly Egorov <[email protected]>
21
 *
22
 */
23
class ArrayValue implements PropertyConfiguratorInterface, ParameterConfiguratorInterface, AttributeConfiguratorInterface
24
{
25
    /** @var string Configurator key */
26
    const KEY = 'array';
27
28
    /**
29
     * @var string Property/Parameter array value
30
     */
31
    protected $value = [];
32
33
    /**
34
     * Class collection configurator constructor.
35
     *
36
     * @param string $value Property/Parameter array value
37
     */
38
    public function __construct(string $value)
39
    {
40
        foreach (explode(',', trim($value)) as $item) {
41
            list($itemKey, $itemValue) = explode('=>', $item);
42
            $this->value[trim($itemKey)] = trim($itemValue);
43
        }
44
    }
45
46
    /* {@inheritDoc} */
47
    public function toPropertyMetadata(PropertyMetadata $propertyMetadata)
48
    {
49
        $propertyMetadata->dependency = $this->value;
50
    }
51
52
    /* {@inheritDoc} */
53
    public function toParameterMetadata(ParameterMetadata $parameterMetadata)
54
    {
55
        $parameterMetadata->dependency = $this->value;
56
    }
57
}
58