Completed
Push — master ( dc2855...0a5beb )
by z38
03:37
created

IS1CreditTransfer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 5
Bugs 1 Features 3
Metric Value
c 5
b 1
f 3
dl 0
loc 39
wmc 3
lcom 1
cbo 2
ccs 12
cts 14
cp 0.8571
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A asDom() 0 16 2
1
<?php
2
3
namespace Z38\SwissPayment\TransactionInformation;
4
5
use DOMDocument;
6
use Z38\SwissPayment\Money;
7
use Z38\SwissPayment\PaymentInformation\PaymentInformation;
8
use Z38\SwissPayment\PostalAccount;
9
use Z38\SwissPayment\PostalAddressInterface;
10
11
/**
12
 * IS1CreditTransfer contains all the information about a IS 1-stage (type 2.1) transaction.
13
 */
14
class IS1CreditTransfer extends CreditTransfer
15
{
16
    /**
17
     * @var PostalAccount
18
     */
19
    protected $creditorAccount;
20
21
    /**
22
     * {@inheritdoc}
23
     *
24
     * @param PostalAccount $creditorAccount Postal account of the creditor
25
     */
26 2
    public function __construct($instructionId, $endToEndId, Money\CHF $amount, $creditorName, PostalAddressInterface $creditorAddress, PostalAccount $creditorAccount)
27
    {
28 2
        parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress);
29
30 2
        $this->creditorAccount = $creditorAccount;
31 2
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36 2
    public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation)
37
    {
38 2
        $root = $this->buildHeader($doc, $paymentInformation, 'CH02');
39
40 2
        $root->appendChild($this->buildCreditor($doc));
41
42 2
        $creditorAccount = $doc->createElement('CdtrAcct');
43 2
        $creditorAccount->appendChild($this->creditorAccount->asDom($doc));
44 2
        $root->appendChild($creditorAccount);
45
46 2
        if ($this->hasRemittanceInformation()) {
47
            $root->appendChild($this->buildRemittanceInformation($doc));
48
        }
49
50 2
        return $root;
51
    }
52
}
53