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

PropRule   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 7
c 2
b 1
f 1
lcom 1
cbo 0
dl 0
loc 56
ccs 13
cts 13
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getKey() 0 4 2
A getProp() 0 4 1
A getSet() 0 4 1
A getType() 0 4 1
A getGetter() 0 4 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