Completed
Push — master ( dc0c42...1f841e )
by Carlos C
11:21
created

Map::getKeyType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php namespace GenericCollections;
2
3
use GenericCollections\Abstracts\AbstractMap;
4
use GenericCollections\Utils\TypeProperty;
5
use GenericCollections\Utils\TypeKeyProperty;
6
7
class Map extends AbstractMap
8
{
9
    /**
10
     * @var TypeProperty
11
     */
12
    private $valueType;
13
14
    /**
15
     * @var TypeKeyProperty
16
     */
17
    private $keyType;
18
19
    /**
20
     * Comparison types
21
     * @var bool
22
     */
23
    private $comparisonIdentical;
24
25
    /**
26
     * Generic map
27
     *
28
     * example:
29
     * ```php
30
     * new Map('string', Foo::class, [
31
     *     'one' => new Foo(),
32
     *     'two' => new Foo(),
33
     * ];
34
     * ```
35
     *
36
     * @param string $keyType
37
     * @param string $valueType
38
     * @param array $values
39
     * @param bool $comparisonIdentical
40
     */
41
    public function __construct($keyType, $valueType, array $values = [], $comparisonIdentical = true)
42
    {
43
        $this->keyType = new TypeKeyProperty($keyType);
44
        $this->valueType = new TypeProperty($valueType);
45
        $this->comparisonIdentical = (bool) $comparisonIdentical;
46
        $this->putAll($values);
47
    }
48
49
    // implements MapInterface::getKeyType : bool
50
    public function getKeyType()
51
    {
52
        return (string) $this->keyType;
53
    }
54
55
    // implements MapInterface::getValueType : bool
56
    public function getValueType()
57
    {
58
        return (string) $this->valueType;
59
    }
60
61
    // implements MapInterface::comparisonMethodIsIdentical : bool
62
    public function comparisonMethodIsIdentical()
63
    {
64
        return $this->comparisonIdentical;
65
    }
66
}
67