Completed
Push — master ( 836ed7...1d0973 )
by Hannes
03:35 queued 02:19
created

NordeaPersonal::getNumber()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
dl 10
loc 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
crap 1
1
<?php
2
3
namespace byrokrat\banking;
4
5
use byrokrat\id\PersonalId;
6
7
/**
8
 * Account number where the serial number is a swedish personal id
9
 */
10
class NordeaPersonal extends BaseAccount
11
{
12
    /**
13
     * Default to clearing 3300 if no clearing is specified
14
     */
15 32
    public function getClearingNumber()
16
    {
17 32
        return parent::getClearingNumber() ?: '3300';
18
    }
19
20
    /**
21
     * Get personal id associated with this account number
22
     *
23
     * @return PersonalId
24
     */
25 1
    public function getPersonalId()
26
    {
27 1
        return new PersonalId($this->getSerialNumber() . $this->getCheckDigit());
28
    }
29
30
    /**
31
     * Strip optional delimiter from serial number
32
     *
33
     * @return string
34
     */
35 32
    public function getSerialNumber()
36
    {
37 32
        return str_replace('-', '', parent::getSerialNumber());
38
    }
39
40
    /**
41
     * Format account number as personal id
42
     */
43 18 View Code Duplication
    public function getNumber()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45 18
        return sprintf(
46 18
            '%s,%s-%s%s',
47 18
            $this->getClearingNumber(),
48 18
            substr($this->getSerialNumber(), 0, -3),
49 18
            substr($this->getSerialNumber(), -3),
50 18
            $this->getCheckDigit()
51
        );
52
    }
53
}
54