1 | <?php |
||
11 | class PostalAccount implements AccountInterface |
||
12 | { |
||
13 | const PATTERN = '/^[0-9]{2}-[1-9][0-9]{0,5}-[0-9]$/'; |
||
14 | |||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | protected $prefix; |
||
19 | |||
20 | /** |
||
21 | * @var int |
||
22 | */ |
||
23 | protected $number; |
||
24 | |||
25 | /** |
||
26 | * @var int |
||
27 | */ |
||
28 | protected $checkDigit; |
||
29 | |||
30 | /** |
||
31 | * Constructor |
||
32 | * |
||
33 | * @param string $postalAccount |
||
34 | * |
||
35 | * @throws InvalidArgumentException When the account number is not valid. |
||
36 | */ |
||
37 | 17 | public function __construct($postalAccount) |
|
52 | |||
53 | /** |
||
54 | * Format the postal account number |
||
55 | * |
||
56 | * @return string The formatted account number |
||
57 | */ |
||
58 | 9 | public function format() |
|
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | 2 | public function asDom(DOMDocument $doc) |
|
75 | |||
76 | 2 | private static function calculateCheckDigit($number) |
|
86 | } |
||
87 |
If you have a function call in the test part of a
for
loop, this function is executed on each iteration. Often such a function, can be moved to the initialization part and be cached.