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