1 | <?php |
||
11 | final class JudiciaryProcess extends AbstractDocument |
||
12 | { |
||
13 | const LENGTH = 20; |
||
14 | |||
15 | const LABEL = 'PROCESSO_JUDICIAL'; |
||
16 | |||
17 | const REGEX = '/^([\d]{7})([\d]{2})([\d]{4})([\d]{1})([\d]{2})([\d]{0,4})$/'; |
||
18 | |||
19 | 11 | public function __construct($number) |
|
20 | { |
||
21 | 11 | $number = preg_replace('/\D/', '', $number); |
|
22 | 11 | parent::__construct($number, self::LENGTH, 2, self::LABEL); |
|
23 | 4 | } |
|
24 | |||
25 | 2 | public function format() |
|
26 | { |
||
27 | 2 | $number = str_pad($this->number, self::LENGTH, '0', STR_PAD_RIGHT); |
|
28 | 2 | return preg_replace(self::REGEX, '$1-$2.$3.$4.$5.$6', "{$number}"); |
|
29 | } |
||
30 | |||
31 | 11 | protected function extractCheckerDigit($number) |
|
35 | |||
36 | 8 | protected function extractBaseNumber($number) |
|
37 | { |
||
38 | 8 | return str_pad(substr($number, 0, 7) |
|
39 | 8 | . substr($number, 9, strlen($number)-1), self::LENGTH, '0', STR_PAD_RIGHT); |
|
40 | } |
||
41 | |||
42 | /** |
||
43 | * Calculate check digit Algoritm Module 97 Base 10 (ISO 7064) |
||
44 | * Anexo VIII da Resolução CNJ no 65, de 16 de dezembro de 2008. |
||
45 | * @param string $input |
||
46 | * @return string |
||
47 | */ |
||
48 | 8 | public function calculateDigit($input) |
|
65 | } |
||
66 |