1 | <?php |
||
9 | class Iban |
||
10 | { |
||
11 | /** |
||
12 | * @var BbanInterface |
||
13 | */ |
||
14 | private $bban; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $countryCode; |
||
20 | |||
21 | /** |
||
22 | * @var string |
||
23 | */ |
||
24 | private $checkDigits; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private static $countriesSupported = [ |
||
30 | 'ES' => SpainBban::class, |
||
31 | ]; |
||
32 | |||
33 | /** |
||
34 | * Iban constructor. |
||
35 | * |
||
36 | * @param string $countryCode |
||
37 | * @param string $checkDigits |
||
38 | * @param BbanInterface $bban |
||
39 | * |
||
40 | * @throws InvalidArgumentException |
||
41 | */ |
||
42 | public function __construct($countryCode, $checkDigits, BbanInterface $bban) |
||
52 | |||
53 | /** |
||
54 | * @param string $iban |
||
55 | * |
||
56 | * @throws InvalidArgumentException |
||
57 | * |
||
58 | * @return static |
||
59 | */ |
||
60 | public static function fromString($iban) |
||
87 | |||
88 | /** |
||
89 | * @return string |
||
90 | */ |
||
91 | public function countryCode() |
||
95 | |||
96 | /** |
||
97 | * @return string |
||
98 | */ |
||
99 | public function ibanCheckDigits() |
||
103 | |||
104 | /** |
||
105 | * @return string |
||
106 | */ |
||
107 | public function bankCode() |
||
111 | |||
112 | /** |
||
113 | * @return string |
||
114 | */ |
||
115 | public function branchCode() |
||
119 | |||
120 | /** |
||
121 | * @return string |
||
122 | */ |
||
123 | public function countryCheckDigits() |
||
127 | |||
128 | /** |
||
129 | * @return string |
||
130 | */ |
||
131 | public function accountNumber() |
||
135 | |||
136 | /** |
||
137 | * @return string |
||
138 | */ |
||
139 | public function __toString() |
||
145 | |||
146 | /** |
||
147 | * @param $countryCode |
||
148 | * |
||
149 | * @throws InvalidArgumentException |
||
150 | */ |
||
151 | private static function validateCountryCodeFormat($countryCode) |
||
157 | |||
158 | /** |
||
159 | * @param $checkDigits |
||
160 | * |
||
161 | * @throws InvalidArgumentException |
||
162 | */ |
||
163 | private static function validateCheckDigitsFormat($checkDigits) |
||
169 | |||
170 | /** |
||
171 | * @param string $countryCode |
||
172 | * @param string $checkDigits |
||
173 | * @param BbanInterface $bban |
||
174 | * |
||
175 | * @throws InvalidArgumentException |
||
176 | */ |
||
177 | private static function validateControlDigit( |
||
192 | |||
193 | /** |
||
194 | * @param string $value |
||
195 | * |
||
196 | * @return int |
||
197 | */ |
||
198 | private static function digitToInt($value) |
||
206 | } |
||
207 |
Let’s assume you have a class which uses late-static binding:
}
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()
on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClass
to useself
instead: