Total Complexity | 4 |
Total Lines | 26 |
Duplicated Lines | 0 % |
Coverage | 100% |
Changes | 0 |
1 | <?php |
||
14 | trait HasIban |
||
15 | { |
||
16 | #[ORM\Column(type: 'string', length: 34, options: ['default' => ''])] |
||
17 | private string $iban = ''; |
||
18 | |||
19 | /** |
||
20 | * Set the IBAN (international bank account number). |
||
21 | */ |
||
22 | 2 | public function setIban(string $iban): void |
|
23 | { |
||
24 | 2 | $iban = str_replace(' ', '', mb_strtoupper($iban)); |
|
25 | |||
26 | 2 | $validator = new Iban(['allow_non_sepa' => false]); |
|
27 | 2 | if (empty($iban) || $validator->isValid($iban)) { |
|
28 | 2 | $this->iban = $iban; |
|
29 | } else { |
||
30 | 1 | throw new Exception('Invalid IBAN number'); |
|
31 | } |
||
32 | } |
||
33 | |||
34 | /** |
||
35 | * Get the IBAN (international bank account number). |
||
36 | */ |
||
37 | 1 | public function getIban(): string |
|
40 | } |
||
41 | } |
||
42 |