Completed
Push — master ( 4d3436...c8d1ff )
by Hanish
11s queued 10s
created

Iban   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 81.82%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 40
ccs 9
cts 11
cp 0.8182
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getIban() 0 4 1
A __toString() 0 4 1
A equals() 0 4 1
1
<?php
2
namespace Genkgo\Camt;
3
4
/**
5
 * Class Iban
6
 * @package Genkgo\Camt
7
 */
8
class Iban
9
{
10
    /**
11
     * @var string
12
     */
13
    private $iban;
14
15
    /**
16
     * @param string $iban
17
     */
18 24
    public function __construct($iban)
19
    {
20 24
        if (!verify_iban($iban)) {
21 1
            throw new \InvalidArgumentException("Unknown IBAN {$iban}");
22
        }
23
        
24 23
        $this->iban = iban_to_machine_format($iban);
25 23
    }
26
27
    /**
28
     * @return string
29
     */
30 2
    public function getIban()
31
    {
32 2
        return $this->iban;
33
    }
34
35
    /**
36
     * @return string
37
     */
38 7
    public function __toString()
39
    {
40 7
        return $this->iban;
41
    }
42
43
    public function equals($iban)
44
    {
45
        return iban_to_machine_format($iban) === $this->iban;
46
    }
47
}
48