Completed
Push — master ( f96168...dfe6c2 )
by Alexpts
04:31
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 1
Bugs 0 Features 1
Metric Value
wmc 7
c 1
b 0
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 getGet() 0 4 1
A getType() 0 4 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
}