Completed
Pull Request — master (#12)
by lee
06:13
created

GenericState::getClassName()   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 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Brazanation\States\Console\Commands\Generate;
4
5
class GenericState
6
{
7
    private $className;
8
9
    private $code;
10
11
    private $fullName;
12
13
    private $shortName;
14
15
    private $timeZone;
16
17
    /**
18
     * GenericState constructor.
19
     *
20
     * @param int    $code
21
     * @param string $fullName
22
     * @param string $shortName
23
     * @param string $timeZone
24
     */
25 3
    public function __construct($code, $fullName, $shortName, $timeZone)
26
    {
27 3
        $this->className = $this->normalizeClassName($fullName);
28 3
        $this->code = (int) $code;
29 3
        $this->fullName = $fullName;
30 3
        $this->shortName = $shortName;
31 3
        $this->timeZone = $timeZone;
32 3
    }
33
34 3
    private function normalizeClassName($fullName)
35
    {
36 3
        $ascName = iconv('utf-8', 'ascii//TRANSLIT', $fullName);
37 3
        $className = str_replace(' ', '', ucwords($ascName));
38
39 3
        return $className;
40
    }
41
42
    /**
43
     * @return string
44
     */
45 1
    public function getClassName()
46
    {
47 1
        return $this->className;
48
    }
49
50
    /**
51
     * @return int
52
     */
53 3
    public function getCode()
54
    {
55 3
        return $this->code;
56
    }
57
58
    /**
59
     * @return string
60
     */
61 1
    public function getFullName()
62
    {
63 1
        return $this->fullName;
64
    }
65
66
    /**
67
     * @return string
68
     */
69 1
    public function getShortName()
70
    {
71 1
        return $this->shortName;
72
    }
73
74
    /**
75
     * @return string
76
     */
77 1
    public function getTimeZone()
78
    {
79 1
        return $this->timeZone;
80
    }
81
82
    /**
83
     * @return bool
84
     */
85 3
    public function isState()
86
    {
87 3
        return $this->getCode() > 0;
88
    }
89
}
90