1 | <?php |
||
10 | class PostalAccount implements AccountInterface |
||
11 | { |
||
12 | const PATTERN = '/^[0-9]{2}-[1-9][0-9]{0,5}-[0-9]$/'; |
||
13 | |||
14 | /** |
||
15 | * @var int |
||
16 | */ |
||
17 | protected $prefix; |
||
18 | |||
19 | /** |
||
20 | * @var int |
||
21 | */ |
||
22 | protected $number; |
||
23 | |||
24 | /** |
||
25 | * @var int |
||
26 | */ |
||
27 | protected $checkDigit; |
||
28 | |||
29 | /** |
||
30 | * Constructor |
||
31 | * |
||
32 | * @param string $postalAccount |
||
33 | * |
||
34 | * @throws \InvalidArgumentException When the account number is not valid (check digit is not being tested). |
||
35 | */ |
||
36 | 8 | public function __construct($postalAccount) |
|
51 | |||
52 | /** |
||
53 | * Format the postal account number |
||
54 | * |
||
55 | * @return string The formatted account number |
||
56 | */ |
||
57 | 6 | public function format() |
|
61 | |||
62 | /** |
||
63 | * {@inheritdoc} |
||
64 | */ |
||
65 | 2 | public function asDom(DOMDocument $doc) |
|
74 | |||
75 | /** |
||
76 | * Checks whether a given prefix is valid |
||
77 | * |
||
78 | * @param int $prefix The prefix to be checked |
||
79 | * |
||
80 | * @return bool True if the prefix is valid |
||
81 | */ |
||
82 | 2 | private static function checkPrefix($prefix) |
|
93 | } |
||
94 |