PropRule::getKey()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

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