Completed
Branch master (67de1a)
by Markus
04:26 queued 01:55
created

GetSEPAAccounts   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 46
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createModelFromArray() 0 11 1
A getSEPAAccountsArray() 0 15 3
1
<?php
2
3
namespace Fhp\Response;
4
5
use Fhp\Model\SEPAAccount;
6
7
/**
8
 * Class GetSEPAAccounts
9
 * @package Fhp\Response
10
 */
11
class GetSEPAAccounts extends Response
12
{
13
    const SEG_ACCOUNT_INFORMATION = 'HISPA';
14
15
    /** @var array */
16
    protected $accounts = array();
17
18
    /**
19
     * Creates SEPA Account array list with SEPAAccount models.
20
     *
21
     * @return SEPAAccount[]
22
     */
23
    public function getSEPAAccountsArray()
24
    {
25
        $accounts = $this->findSegment(static::SEG_ACCOUNT_INFORMATION);
26
27
        if (is_string($accounts)) {
28
            $accounts = $this->splitSegment($accounts);
29
            array_shift($accounts);
30
            foreach ($accounts as $account) {
31
                $array = $this->splitDeg($account);
32
                $this->accounts[] = $this->createModelFromArray($array);
33
            }
34
        }
35
36
        return $this->accounts;
37
    }
38
39
    /**
40
     * Creates a SEPAAccount model from array.
41
     *
42
     * @param array $array
43
     * @return SEPAAccount
44
     */
45
    protected function createModelFromArray(array $array)
46
    {
47
        $account = new SEPAAccount();
48
        $account->setIban($array[1]);
49
        $account->setBic($array[2]);
50
        $account->setAccountNumber($array[3]);
51
        $account->setSubAccount($array[4]);
52
        $account->setBlz($array[6]);
53
54
        return $account;
55
    }
56
}
57