1 | <?php |
||
12 | class OcrTools |
||
13 | { |
||
14 | /** |
||
15 | * @var Luhn Checksum calculator |
||
16 | */ |
||
17 | private $luhn; |
||
18 | |||
19 | 17 | public function __construct(Luhn $luhn = null) |
|
23 | |||
24 | /** |
||
25 | * Validate OCR number |
||
26 | * |
||
27 | * @throws Exception If ocr is not valid, including check and length digits |
||
28 | */ |
||
29 | 7 | public function validateOcr(string $ocr): string |
|
45 | |||
46 | /** |
||
47 | * Create ocr from number by appending check and length digits |
||
48 | * |
||
49 | * @throws Exception If number is non-numeric or longer than 23 characters |
||
50 | */ |
||
51 | 4 | public function createOcr(string $number): string |
|
62 | |||
63 | /** |
||
64 | * Calculate length digit for raw number |
||
65 | * |
||
66 | * The length of $number plus 2 is used, to take length and check digits |
||
67 | * into account. |
||
68 | */ |
||
69 | 6 | private function calculateLengthDigit(string $number): string |
|
73 | } |
||
74 |