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

SEPACreditTransfer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 90%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 3
dl 0
loc 53
ccs 18
cts 20
cp 0.9
rs 10

2 Methods

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