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

CollectionItem::getValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
cc 1
eloc 2
nc 1
nop 0
crap 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