1 | <?php |
||
38 | final class StateRegistration extends AbstractDocument |
||
39 | { |
||
40 | /** |
||
41 | * @var StateRegistration\StateInterface |
||
42 | */ |
||
43 | private $state; |
||
44 | |||
45 | /** |
||
46 | * @var array |
||
47 | */ |
||
48 | private static $availableStates = [ |
||
49 | StateRegistration\Acre::SHORT_NAME => StateRegistration\Acre::class, |
||
50 | StateRegistration\Alagoas::SHORT_NAME => StateRegistration\Alagoas::class, |
||
51 | StateRegistration\Amapa::SHORT_NAME => StateRegistration\Amapa::class, |
||
52 | StateRegistration\Amazonas::SHORT_NAME => StateRegistration\Amazonas::class, |
||
53 | StateRegistration\Bahia::SHORT_NAME => StateRegistration\Bahia::class, |
||
54 | StateRegistration\Ceara::SHORT_NAME => StateRegistration\Ceara::class, |
||
55 | StateRegistration\DistritoFederal::SHORT_NAME => StateRegistration\DistritoFederal::class, |
||
56 | StateRegistration\EspiritoSanto::SHORT_NAME => StateRegistration\EspiritoSanto::class, |
||
57 | StateRegistration\Goias::SHORT_NAME => StateRegistration\Goias::class, |
||
58 | StateRegistration\Maranhao::SHORT_NAME => StateRegistration\Maranhao::class, |
||
59 | StateRegistration\MatoGrosso::SHORT_NAME => StateRegistration\MatoGrosso::class, |
||
60 | StateRegistration\MatoGrossoSul::SHORT_NAME => StateRegistration\MatoGrossoSul::class, |
||
61 | StateRegistration\MinasGerais::SHORT_NAME => StateRegistration\MinasGerais::class, |
||
62 | StateRegistration\Para::SHORT_NAME => StateRegistration\Para::class, |
||
63 | StateRegistration\Paraiba::SHORT_NAME => StateRegistration\Paraiba::class, |
||
64 | StateRegistration\Parana::SHORT_NAME => StateRegistration\Parana::class, |
||
65 | StateRegistration\Pernambuco::SHORT_NAME => StateRegistration\Pernambuco::class, |
||
66 | StateRegistration\Piaui::SHORT_NAME => StateRegistration\Piaui::class, |
||
67 | StateRegistration\RioDeJaneiro::SHORT_NAME => StateRegistration\RioDeJaneiro::class, |
||
68 | StateRegistration\RioGrandeDoNorte::SHORT_NAME => StateRegistration\RioGrandeDoNorte::class, |
||
69 | StateRegistration\RioGrandeDoSul::SHORT_NAME => StateRegistration\RioGrandeDoSul::class, |
||
70 | StateRegistration\Rondonia::SHORT_NAME => StateRegistration\Rondonia::class, |
||
71 | StateRegistration\Roraima::SHORT_NAME => StateRegistration\Roraima::class, |
||
72 | StateRegistration\SantaCatarina::SHORT_NAME => StateRegistration\SantaCatarina::class, |
||
73 | StateRegistration\SaoPaulo::SHORT_NAME => StateRegistration\SaoPaulo::class, |
||
74 | StateRegistration\Sergipe::SHORT_NAME => StateRegistration\Sergipe::class, |
||
75 | StateRegistration\Tocantins::SHORT_NAME => StateRegistration\Tocantins::class, |
||
76 | ]; |
||
77 | |||
78 | /** |
||
79 | * StateRegistration constructor. |
||
80 | * |
||
81 | * @param string $number |
||
82 | * @param StateRegistration\StateInterface $state |
||
83 | */ |
||
84 | 966 | public function __construct($number, StateRegistration\StateInterface $state) |
|
85 | { |
||
86 | 966 | $number = $state->normalizeNumber($number); |
|
87 | 966 | $this->state = $state; |
|
88 | 966 | parent::__construct($number, $state->getLength(), $state->getNumberOfDigits(), $state->getState()); |
|
89 | 780 | } |
|
90 | |||
91 | /** |
||
92 | * Try to create a StateRegistration object from given number and state short name. |
||
93 | * |
||
94 | * @param string $number Document number to be parsed. |
||
95 | * @param string $state State short name. |
||
96 | * |
||
97 | * @return AbstractDocument|boolean Returns a new Document instance or FALSE on failure. |
||
98 | */ |
||
99 | 483 | public static function createFromString($number, $state = '') |
|
107 | |||
108 | /** |
||
109 | * @param string $name |
||
110 | * @param array $arguments |
||
111 | * |
||
112 | * @return StateRegistration |
||
113 | * |
||
114 | * @throws \ReflectionException |
||
115 | */ |
||
116 | 503 | public static function __callStatic($name, $arguments) |
|
126 | |||
127 | /** |
||
128 | * {@inheritdoc} |
||
129 | */ |
||
130 | 888 | protected function extractBaseNumber($number) |
|
134 | |||
135 | /** |
||
136 | * {@inheritdoc} |
||
137 | */ |
||
138 | 966 | protected function extractCheckerDigit($number) |
|
142 | |||
143 | /** |
||
144 | * Voter does not has a specific format. |
||
145 | * |
||
146 | * @return string Returns only numbers. |
||
147 | */ |
||
148 | 82 | public function format() |
|
152 | |||
153 | /** |
||
154 | * {@inheritdoc} |
||
155 | */ |
||
156 | 834 | public function calculateDigit($baseNumber) |
|
162 | } |
||
163 |