Completed
Pull Request — master (#4)
by Leo
07:33
created

State   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 11
lcom 1
cbo 0
dl 0
loc 54
ccs 21
cts 21
cp 1
rs 10
c 0
b 0
f 0

10 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getData() 0 4 1
A getItem() 0 4 2
A getName() 0 4 1
A getAbbr() 0 4 1
A getCapital() 0 4 1
A getRegion() 0 4 1
A getTimezone() 0 4 1
A getDst() 0 4 1
A getSlug() 0 4 1
1
<?php
2
3
namespace Brazanation\States;
4
5
class State implements StateInterface
6
{
7
    protected $data;
8
9 38
    public function __construct(array $data)
10
    {
11 38
        $this->data = $data;
12 38
    }
13
14 1
    public function getData()
15
    {
16 1
        return $this->data;
17
    }
18
19 36
    public function getItem($key, $default = null)
20
    {
21 36
        return array_key_exists($key, $this->data) ? $this->data[$key] : $default;
22
    }
23
24 28
    public function getName()
25
    {
26 28
        return $this->getItem('name');
27
    }
28
29 28
    public function getAbbr()
30
    {
31 28
        return $this->getItem('abbr');
32
    }
33
34 28
    public function getCapital()
35
    {
36 28
        return $this->getItem('capital');
37
    }
38
39 28
    public function getRegion()
40
    {
41 28
        return $this->getItem('region');
42
    }
43
44 28
    public function getTimezone()
45
    {
46 28
        return $this->getItem('timezone');
47
    }
48
49 28
    public function getDst()
50
    {
51 28
        return $this->getItem('dst');
52
    }
53
54 28
    public function getSlug()
55
    {
56 28
        return $this->getItem('slug');
57
    }
58
}
59