Completed
Push — scrutinizer ( 42ac6a...7bc18e )
by z38
02:40
created

IS1CreditTransfer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 6
crap 1
1
<?php
2
3
namespace Z38\SwissPayment\TransactionInformation;
4
5
use Z38\SwissPayment\Money;
6
use Z38\SwissPayment\PostalAccount;
7
use Z38\SwissPayment\PostalAddressInterface;
8
9
/**
10
 * IS1CreditTransfer contains all the information about a IS 1-stage (type 2.1) transaction.
11
 */
12
class IS1CreditTransfer extends CreditTransfer
13
{
14
    /**
15
     * @var PostalAccount
16
     */
17
    protected $creditorAccount;
18
19
    /**
20
     * {@inheritdoc}
21
     *
22
     * @param PostalAccount $creditorAccount Postal account of the creditor
23
     */
24 2
    public function __construct($instructionId, $endToEndId, Money\CHF $amount, $creditorName, PostalAddressInterface $creditorAddress, PostalAccount $creditorAccount)
25
    {
26 2
        parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress);
27
28 2
        $this->creditorAccount = $creditorAccount;
29 2
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34 2
    public function asDom(\DOMDocument $doc)
35
    {
36 2
        $root = $this->buildHeader($doc, 'CH02');
37
38 2
        $root->appendChild($this->buildCreditor($doc));
39
40 2
        $creditorAccount = $doc->createElement('CdtrAcct');
41 2
        $creditorAccountId = $doc->createElement('Id');
42 2
        $creditorAccountIdOther = $doc->createElement('Othr');
43 2
        $creditorAccountIdOther->appendChild($doc->createElement('Id', $this->creditorAccount->format()));
44 2
        $creditorAccountId->appendChild($creditorAccountIdOther);
45 2
        $creditorAccount->appendChild($creditorAccountId);
46 2
        $root->appendChild($creditorAccount);
47
48 2
        if ($this->hasRemittanceInformation()) {
49
            $root->appendChild($this->buildRemittanceInformation($doc));
50
        }
51
52 2
        return $root;
53
    }
54
}
55