Completed
Push — master ( d10f54...00ced4 )
by
unknown
05:32
created

CollectionItem   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 52
rs 10
c 0
b 0
f 0
ccs 12
cts 12
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getKey() 0 4 1
A getValue() 0 4 1
A create() 0 7 1
1
<?php declare(strict_types = 1);
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 02.08.16
6
 * Time: 0:46.
7
 */
8
namespace samsonframework\container\definition\reference;
9
10
use samsonframework\container\definition\builder\exception\ReferenceNotImplementsException;
11
12
/**
13
 * Class CollectionReference
14
 *
15
 * @author Ruslan Molodyko <[email protected]>
16
 */
17
class CollectionItem
18
{
19
    /** @var mixed Key of item */
20
    protected $key;
21
    /** @var mixed Value of item */
22
    protected $value;
23
24
    /**
25
     * CollectionItem constructor.
26
     *
27
     * @param ReferenceInterface $key
28
     * @param ReferenceInterface $value
29
     */
30 18
    public function __construct(ReferenceInterface $key, ReferenceInterface $value)
31
    {
32 18
        $this->key = $key;
33 18
        $this->value = $value;
34 18
    }
35
36
    /**
37
     * @return mixed
38
     */
39 14
    public function getKey()
40
    {
41 14
        return $this->key;
42
    }
43
44
    /**
45
     * @return mixed
46
     */
47 12
    public function getValue()
48
    {
49 12
        return $this->value;
50
    }
51
52
    /**
53
     * Create collection item from php type
54
     *
55
     * @param $key
56
     * @param $value
57
     * @return CollectionItem
58
     * @throws ReferenceNotImplementsException
59
     * @throws \InvalidArgumentException
60
     */
61 9
    public static function create($key, $value)
62
    {
63 9
        return new CollectionItem(
64 9
            CollectionReference::convertValueToReference($key),
65 9
            CollectionReference::convertValueToReference($value)
66
        );
67
    }
68
}
69