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

SEPACreditTransfer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 88.89%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A asDom() 0 21 2
1
<?php
2
3
namespace Z38\SwissPayment\TransactionInformation;
4
5
use DOMDocument;
6
use Z38\SwissPayment\BIC;
7
use Z38\SwissPayment\IBAN;
8
use Z38\SwissPayment\Money;
9
use Z38\SwissPayment\PaymentInformation\PaymentInformation;
10
use Z38\SwissPayment\PostalAddressInterface;
11
12
/**
13
 * SEPACreditTransfer contains all the information about a foreign SEPA (type 5) transaction.
14
 */
15
class SEPACreditTransfer extends CreditTransfer
16
{
17
    /**
18
     * @var IBAN
19
     */
20
    protected $creditorIBAN;
21
22
    /**
23
     * @var BIC
24
     */
25
    protected $creditorAgentBIC;
26
27
    /**
28
     * {@inheritdoc}
29
     *
30
     * @param IBAN $creditorIBAN     IBAN of the creditor
31
     * @param BIC  $creditorAgentBIC BIC of the creditor's financial institution
32
     */
33 2
    public function __construct($instructionId, $endToEndId, Money\EUR $amount, $creditorName, PostalAddressInterface $creditorAddress, IBAN $creditorIBAN, BIC $creditorAgentBIC)
34
    {
35 2
        parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress);
36
37 2
        $this->creditorIBAN = $creditorIBAN;
38 2
        $this->creditorAgentBIC = $creditorAgentBIC;
39 2
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 2
    public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation)
45
    {
46 2
        $root = $this->buildHeader($doc, $paymentInformation, null, 'SEPA');
47
48 2
        $creditorAgent = $doc->createElement('CdtrAgt');
49
50 2
        $creditorAgent->appendChild($this->creditorAgentBIC->asDom($doc));
51 2
        $root->appendChild($creditorAgent);
52
53 2
        $root->appendChild($this->buildCreditor($doc));
54
55 2
        $creditorAccount = $doc->createElement('CdtrAcct');
56 2
        $creditorAccount->appendChild($this->creditorIBAN->asDom($doc));
57 2
        $root->appendChild($creditorAccount);
58
59 2
        if ($this->hasRemittanceInformation()) {
60
            $root->appendChild($this->buildRemittanceInformation($doc));
61
        }
62
63 2
        return $root;
64
    }
65
}
66