Completed
Push — master ( f96168...dfe6c2 )
by Alexpts
04:31
created

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