SEPACreditTransfer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 59
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 2
A asDom() 0 24 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
11
/**
12
 * SEPACreditTransfer contains all the information about a foreign SEPA (type 5) transaction.
13
 */
14
class SEPACreditTransfer extends CreditTransfer
15
{
16
    /**
17
     * @var IBAN
18
     */
19
    protected $creditorIBAN;
20
21
    /**
22
     * @var BIC|null
23
     */
24
    protected $creditorAgentBIC;
25
26
    /**
27
     * {@inheritdoc}
28
     *
29
     * @param IBAN     $creditorIBAN     IBAN of the creditor
30
     * @param BIC|null $creditorAgentBIC BIC of the creditor's financial institution
31
     */
32 3
    public function __construct($instructionId, $endToEndId, Money\EUR $amount, $creditorName, $creditorAddress, IBAN $creditorIBAN, BIC $creditorAgentBIC = null)
33
    {
34 3
        parent::__construct($instructionId, $endToEndId, $amount, $creditorName, $creditorAddress);
35
36 3
        $this->creditorIBAN = $creditorIBAN;
37 3
        $this->serviceLevel = 'SEPA';
38
39 3
        if ($creditorAgentBIC !== null) {
40 3
            @trigger_error('Setting the creditor agent BIC of SEPA payments is deprecated. The execution of the payment will be based on the IBAN.', E_USER_DEPRECATED);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
41 3
            $this->creditorAgentBIC = $creditorAgentBIC;
42 3
        }
43 3
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48 2
    public function asDom(DOMDocument $doc, PaymentInformation $paymentInformation)
49
    {
50 2
        $root = $this->buildHeader($doc, $paymentInformation);
51
52 2
        $root->appendChild($doc->createElement('ChrgBr', 'SLEV'));
53
54 2
        if ($this->creditorAgentBIC !== null) {
55 2
            $creditorAgent = $doc->createElement('CdtrAgt');
56 2
            $creditorAgent->appendChild($this->creditorAgentBIC->asDom($doc));
57 2
            $root->appendChild($creditorAgent);
58 2
        }
59
60 2
        $root->appendChild($this->buildCreditor($doc));
61
62 2
        $creditorAccount = $doc->createElement('CdtrAcct');
63 2
        $creditorAccount->appendChild($this->creditorIBAN->asDom($doc));
64 2
        $root->appendChild($creditorAccount);
65
66 2
        $this->appendPurpose($doc, $root);
67
68 2
        $this->appendRemittanceInformation($doc, $root);
69
70 2
        return $root;
71
    }
72
}
73