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

Iban::getIban()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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