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

IS1CreditTransfer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 3
Bugs 1 Features 2
Metric Value
wmc 3
c 3
b 1
f 2
lcom 1
cbo 2
dl 0
loc 43
ccs 16
cts 18
cp 0.8889
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A asDom() 0 20 2
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