1 | <?php |
||
10 | class IBAN implements AccountInterface |
||
11 | { |
||
12 | const MAX_LENGTH = 34; |
||
13 | const PATTERN = '/^[A-Z]{2,2}[0-9]{2,2}[A-Z0-9]{1,30}$/'; |
||
14 | |||
15 | /** |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $iban; |
||
19 | |||
20 | /** |
||
21 | * Constructor |
||
22 | * |
||
23 | * @param string $iban |
||
24 | * |
||
25 | * @throws \InvalidArgumentException When the IBAN does contain invalid characters or the checksum calculation fails. |
||
26 | */ |
||
27 | 8 | public function __construct($iban) |
|
39 | |||
40 | /** |
||
41 | * Format the IBAN either in a human-readable manner |
||
42 | * |
||
43 | * @return string The formatted IBAN |
||
44 | */ |
||
45 | 1 | public function format() |
|
51 | |||
52 | /** |
||
53 | * Normalize the IBAN |
||
54 | * |
||
55 | * @return string The normalized IBAN |
||
56 | */ |
||
57 | 3 | public function normalize() |
|
61 | |||
62 | /** |
||
63 | * Gets the country |
||
64 | * |
||
65 | * @return string A ISO 3166-1 alpha-2 country code |
||
66 | */ |
||
67 | 6 | public function getCountry() |
|
71 | |||
72 | /** |
||
73 | * Checks whether the checksum of an IBAN is correct |
||
74 | * |
||
75 | * @param string $iban |
||
76 | * |
||
77 | * @return bool true if checksum is correct, false otherwise |
||
78 | */ |
||
79 | 3 | protected static function check($iban) |
|
104 | |||
105 | /** |
||
106 | * {@inheritdoc} |
||
107 | */ |
||
108 | 2 | public function asDom(DOMDocument $doc) |
|
115 | |||
116 | /** |
||
117 | * Returns a string representation. |
||
118 | * |
||
119 | * @return string The string representation. |
||
120 | */ |
||
121 | 3 | public function __toString() |
|
125 | } |
||
126 |