Completed
Push — master ( 5d18c7...cabcf3 )
by Hannes
16s queued 13s
created

BankAccount::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 1
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace byrokrat\banking;
6
7
/**
8
 * Account number decorator for accounts belonging to a bank
9
 */
10
class BankAccount implements AccountNumber
11
{
12
    use Formatter\FormattableTrait;
13
14
    /**
15
     * @var string The name of the Bank this number belongs to
16
     */
17
    private $bankName;
18
19
    /**
20
     * @var AccountNumber
21
     */
22
    private $decorated;
23
24 89
    public function __construct(string $bankName, AccountNumber $decorated)
25
    {
26 89
        $this->bankName = $bankName;
27 89
        $this->decorated = $decorated;
28 89
    }
29
30 89
    public function getBankName(): string
31
    {
32 89
        return $this->bankName;
33
    }
34
35 1
    public function getRawNumber(): string
36
    {
37 1
        return $this->decorated->getRawNumber();
38
    }
39
40 87
    public function getClearingNumber(): string
41
    {
42 87
        return $this->decorated->getClearingNumber();
43
    }
44
45 87
    public function getClearingCheckDigit(): string
46
    {
47 87
        return $this->decorated->getClearingCheckDigit();
48
    }
49
50 87
    public function getSerialNumber(): string
51
    {
52 87
        return $this->decorated->getSerialNumber();
53
    }
54
55 87
    public function getCheckDigit(): string
56
    {
57 87
        return $this->decorated->getCheckDigit();
58
    }
59
60 87
    public function equals(AccountNumber $account, bool $strict = false): bool
61
    {
62 87
        return $this->decorated->equals($account, $strict) && $this->getBankName() == $account->getBankName();
63
    }
64
65 86
    protected function getFormattable(): AccountNumber
66
    {
67 86
        return $this;
68
    }
69
}
70