State   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 19
dl 0
loc 107
ccs 22
cts 22
cp 1
rs 10
c 2
b 0
f 1
wmc 9

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getLength() 0 3 1
A __construct() 0 7 1
A extractBaseNumber() 0 3 1
A getState() 0 3 1
A getFormat() 0 3 1
A normalizeNumber() 0 3 1
A getRegex() 0 3 1
A extractCheckerDigit() 0 3 1
A getNumberOfDigits() 0 3 1
1
<?php
2
3
namespace Brazanation\Documents\StateRegistration;
4
5
abstract class State implements StateInterface
6
{
7
    /**
8
     * @var string
9
     */
10
    private $state;
11
12
    /**
13
     * @var int
14
     */
15
    private $length;
16
17
    /**
18
     * @var string
19
     */
20
    private $regex;
21
22
    /**
23
     * @var string
24
     */
25
    private $format;
26
27
    /**
28
     * @var int
29
     */
30
    private $numberOfDigits;
31
32
    /**
33
     * State constructor.
34
     *
35
     * @param string $state
36
     * @param int    $length
37
     * @param int    $numberOfDigits
38
     * @param string $regex
39
     * @param string $format
40
     */
41 886
    public function __construct(string $state, int $length, int $numberOfDigits, string $regex, string $format)
42
    {
43 886
        $this->state = $state;
44 886
        $this->length = $length;
45 886
        $this->regex = $regex;
46 886
        $this->format = $format;
47 886
        $this->numberOfDigits = $numberOfDigits;
48
    }
49
50
    /**
51
     * {@inheritdoc}
52
     */
53 886
    public function getState() : string
54
    {
55 886
        return $this->state;
56
    }
57
58
    /**
59
     * {@inheritdoc}
60
     */
61 862
    public function getLength() : int
62
    {
63 862
        return $this->length;
64
    }
65
66
    /**
67
     * {@inheritdoc}
68
     */
69 78
    public function getRegex() : string
70
    {
71 78
        return $this->regex;
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77 78
    public function getFormat() : string
78
    {
79 78
        return $this->format;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85 886
    public function getNumberOfDigits() : int
86
    {
87 886
        return $this->numberOfDigits;
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93 882
    public function normalizeNumber(string $number) : string
94
    {
95 882
        return preg_replace('/\D/', '', $number);
96
    }
97
98
    /**
99
     * {@inheritdoc}
100
     */
101 874
    public function extractBaseNumber(string $number) : string
102
    {
103 874
        return substr($number, 0, -($this->getNumberOfDigits()));
104
    }
105
106
    /**
107
     * {@inheritdoc}
108
     */
109 874
    public function extractCheckerDigit(string $number) : string
110
    {
111 874
        return substr($number, -($this->getNumberOfDigits()));
112
    }
113
}
114