Total Complexity | 4 |
Total Lines | 36 |
Duplicated Lines | 0 % |
Coverage | 90% |
Changes | 0 |
1 | <?php |
||
13 | trait HasIban |
||
14 | { |
||
15 | /** |
||
16 | * @var string |
||
17 | * |
||
18 | * @ORM\Column(type="string", length=34, unique=true, nullable=true) |
||
19 | */ |
||
20 | private $iban; |
||
21 | |||
22 | /** |
||
23 | * Set the IBAN (international bank account number) |
||
24 | * |
||
25 | * @param string $iban |
||
26 | * |
||
27 | * @throws InvalidArgumentException |
||
28 | */ |
||
29 | 1 | public function setIban(string $iban): void |
|
30 | { |
||
31 | 1 | $validator = new \Zend\Validator\Iban(['country_code' => 'CH']); |
|
32 | 1 | if (empty($iban)) { |
|
33 | $this->iban = null; |
||
34 | 1 | } elseif ($validator->isValid($iban)) { |
|
35 | 1 | $this->iban = $iban; |
|
36 | } else { |
||
37 | 1 | throw new InvalidArgumentException('Invalid IBAN number'); |
|
38 | } |
||
39 | 1 | } |
|
40 | |||
41 | /** |
||
42 | * Get the IBAN (international bank account number) |
||
43 | * |
||
44 | * @return string |
||
45 | */ |
||
46 | 1 | public function getIban(): string |
|
49 | } |
||
50 | } |
||
51 |