1 | <?php |
||
7 | abstract class AbstractDocument implements DocumentInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $number; |
||
13 | |||
14 | /** |
||
15 | * @var string |
||
16 | */ |
||
17 | protected $digit; |
||
18 | |||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | protected $length; |
||
23 | |||
24 | /** |
||
25 | * @var int |
||
26 | */ |
||
27 | protected $numberOfDigits; |
||
28 | |||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | protected $type; |
||
33 | |||
34 | /** |
||
35 | * AbstractDocument constructor. |
||
36 | * |
||
37 | * @param string $number Numeric section with checker digit. |
||
38 | * @param int $length Max length of document. |
||
39 | * @param int $numberOfDigits Max length of checker digits. |
||
40 | * @param string $type Document name/type. |
||
41 | */ |
||
42 | 72 | public function __construct($number, $length, $numberOfDigits, $type) |
|
51 | |||
52 | /** |
||
53 | * Check if document number is valid. |
||
54 | * |
||
55 | * @param string $number Numeric section with checker digit. |
||
56 | * |
||
57 | * @throws InvalidDocumentException when number is empty |
||
58 | * @throws InvalidDocumentException when number is not valid |
||
59 | */ |
||
60 | 72 | protected function validate($number) |
|
69 | |||
70 | /** |
||
71 | * Validates number is a valid. |
||
72 | * |
||
73 | * @param string $number Numeric section with checker digit. |
||
74 | * |
||
75 | * @return bool Returns true if it is a valid number, otherwise false. |
||
76 | */ |
||
77 | 54 | protected function isValid($number) |
|
89 | |||
90 | /** |
||
91 | * Handle number to string. |
||
92 | * |
||
93 | * @return string |
||
94 | */ |
||
95 | 26 | public function __toString() |
|
99 | } |
||
100 |