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

BankAccount   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
ccs 20
cts 20
cp 1
wmc 10
lcom 1
cbo 2

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getBankName() 0 4 1
A getRawNumber() 0 4 1
A getClearingNumber() 0 4 1
A getClearingCheckDigit() 0 4 1
A getSerialNumber() 0 4 1
A getCheckDigit() 0 4 1
A equals() 0 4 2
A getFormattable() 0 4 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