1 | <?php |
||
24 | abstract class AbstractAccessKey extends AbstractDocument |
||
25 | { |
||
26 | const NUMBER_OF_DIGITS = 1; |
||
27 | |||
28 | const LABEL = 'SpedAccessKey'; |
||
29 | |||
30 | const LENGTH = 44; |
||
31 | |||
32 | const MASK = '$1 '; |
||
33 | |||
34 | const REGEX = '/([\d]{4})/'; |
||
35 | |||
36 | /** |
||
37 | * @var int |
||
38 | */ |
||
39 | protected $state; |
||
40 | |||
41 | /** |
||
42 | * @var \DateTime |
||
43 | */ |
||
44 | protected $generatedAt; |
||
45 | |||
46 | /** |
||
47 | * @var Cnpj |
||
48 | */ |
||
49 | protected $cnpj; |
||
50 | |||
51 | /** |
||
52 | * @var Model |
||
53 | */ |
||
54 | protected $model; |
||
55 | |||
56 | /** |
||
57 | * @var string |
||
58 | */ |
||
59 | protected $sequence; |
||
60 | |||
61 | /** |
||
62 | * @var string |
||
63 | */ |
||
64 | protected $invoiceNumber; |
||
65 | |||
66 | /** |
||
67 | * @var EmissionType |
||
68 | */ |
||
69 | protected $emissionType; |
||
70 | |||
71 | /** |
||
72 | * @var string |
||
73 | */ |
||
74 | protected $controlNumber; |
||
75 | |||
76 | /** |
||
77 | * SpedAccessKey constructor. |
||
78 | * |
||
79 | * @param $accessKey |
||
80 | */ |
||
81 | 160 | public function __construct($accessKey) |
|
88 | |||
89 | 77 | public static function createFromString($number) |
|
93 | |||
94 | /** |
||
95 | * @return Model |
||
96 | */ |
||
97 | abstract protected function defaultModel(); |
||
98 | |||
99 | 30 | protected function validateModel($accessKey) |
|
106 | |||
107 | 29 | private function loadFromKey($accessKey) |
|
136 | |||
137 | /** |
||
138 | * Generates a valid Sped Access Key. |
||
139 | * |
||
140 | * @param int $state IBGE state code. |
||
141 | * @param \DateTime $generatedAt Year and month when invoice was created. |
||
142 | * @param Cnpj $cnpj Cnpj from issuer. |
||
143 | * @param Model $model Document model. |
||
144 | * @param int $sequence Invoice sequence. |
||
145 | * @param int $invoiceNumber Invoice number. |
||
146 | * @param EmissionType $emissionType Emission Type. |
||
147 | * @param int $controlNumber Control number. |
||
148 | * |
||
149 | * @return AbstractAccessKey |
||
150 | */ |
||
151 | 5 | protected static function generateKey( |
|
175 | |||
176 | /** |
||
177 | * {@inheritdoc} |
||
178 | */ |
||
179 | 10 | public function format() |
|
183 | |||
184 | /** |
||
185 | * {@inheritdoc} |
||
186 | */ |
||
187 | 120 | public function calculateDigit($baseNumber) |
|
191 | |||
192 | /** |
||
193 | * Calculate check digit from base number. |
||
194 | * |
||
195 | * It is static because is used from generate static method. |
||
196 | * |
||
197 | * @param string $baseNumber Base numeric section to be calculate your digit. |
||
198 | * |
||
199 | * @return string |
||
200 | */ |
||
201 | 120 | public static function calculateDigitFrom($baseNumber) |
|
211 | } |
||
212 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()
method in theSon
calls the wrong method in the parent class.