Passed
Push — master ( 64a057...f2bf02 )
by Antonio Oertel
41s
created

GenericState   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 85
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 65.22%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 85
ccs 15
cts 23
cp 0.6522
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getClassName() 0 4 1
A getFullName() 0 4 1
A getShortName() 0 4 1
A getTimeZone() 0 4 1
A __construct() 0 8 1
A normalizeClassName() 0 7 1
A getCode() 0 4 1
A isState() 0 4 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 1
    public function __construct($code, $fullName, $shortName, $timeZone)
26
    {
27 1
        $this->className = $this->normalizeClassName($fullName);
28 1
        $this->code = (int) $code;
29 1
        $this->fullName = $fullName;
30 1
        $this->shortName = $shortName;
31 1
        $this->timeZone = $timeZone;
32 1
    }
33
34 1
    private function normalizeClassName($fullName)
35
    {
36 1
        $ascName = iconv('utf-8', 'ascii//TRANSLIT', $fullName);
37 1
        $className = str_replace(' ', '', ucwords($ascName));
38
39 1
        return $className;
40
    }
41
42
    /**
43
     * @return string
44
     */
45
    public function getClassName()
46
    {
47
        return $this->className;
48
    }
49
50
    /**
51
     * @return int
52
     */
53 1
    public function getCode()
54
    {
55 1
        return $this->code;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getFullName()
62
    {
63
        return $this->fullName;
64
    }
65
66
    /**
67
     * @return string
68
     */
69
    public function getShortName()
70
    {
71
        return $this->shortName;
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getTimeZone()
78
    {
79
        return $this->timeZone;
80
    }
81
82
    /**
83
     * @return bool
84
     */
85 1
    public function isState()
86
    {
87 1
        return $this->getCode() > 0;
88
    }
89
}
90