Iban   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 9
dl 0
loc 28
ccs 10
cts 10
cp 1
rs 10
c 4
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A equals() 0 3 1
A __toString() 0 3 1
A getIban() 0 3 1
A __construct() 0 9 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Genkgo\Camt;
6
7
use Iban\Validation\Iban as IbanDetails;
8
use Iban\Validation\Validator;
9
use InvalidArgumentException;
10
11
class Iban
12
{
13
    private string $iban;
14
15
    public function __construct(string $iban)
16
    {
17
        $iban = new IbanDetails($iban);
18 26
19
        if (!(new Validator())->validate($iban)) {
20 26
            throw new InvalidArgumentException("Unknown IBAN {$iban}");
21
        }
22 26
23 1
        $this->iban = $iban->getNormalizedIban();
24
    }
25
26 25
    public function getIban(): string
27 25
    {
28
        return $this->iban;
29 2
    }
30
31 2
    public function __toString(): string
32
    {
33
        return $this->iban;
34 7
    }
35
36 7
    public function equals(string $iban): bool
37
    {
38
        return (new IbanDetails($iban))->getNormalizedIban() === $this->iban;
39
    }
40
}
41