Completed
Push — master ( 641110...6d20fa )
by Alexpts
03:58
created

PropRule::getGetter()   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
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace PTS\DataTransformer;
3
4
class PropRule
5
{
6
    /** @var array */
7
    protected $map;
8
9
    /**
10
     * @param array $map
11
     */
12 4
    public function __construct(array $map)
13
    {
14 4
        $this->map = $map;
15 4
    }
16
17
    /**
18
     * @param string $name
19
     * @param mixed $default
20
     * @return null|mixed
21
     */
22 4
    public function getKey($name, $default = null)
23
    {
24 4
        return  array_key_exists($name, $this->map) ? $this->map[$name] : $default;
25
    }
26
27
    /**
28
     * @param string|null $default
29
     * @return string|null
30
     */
31 4
    public function getProp($default = null)
32
    {
33 4
        return $this->getKey('prop', $default);
34
    }
35
36
    /**
37
     * @return mixed|null
38
     */
39 2
    public function getSet()
40
    {
41 2
        return $this->getKey('set');
42
    }
43
44
    /**
45
     * @return mixed|null
46
     */
47 2
    public function getGetter()
48
    {
49 2
        return $this->getKey('get');
50
    }
51
52
    /**
53
     * @return string
54
     */
55 4
    public function getType()
56
    {
57 4
        return $this->getKey('type');
58
    }
59
}
60