CashOnDelivery::setBic()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace Bpost\BpostApiClient\Bpost\Order\Box\Option;
3
4
/**
5
 * bPost CashOnDelivery class
6
 *
7
 * @author    Tijs Verkoyen <[email protected]>
8
 * @version   3.0.0
9
 * @copyright Copyright (c), Tijs Verkoyen. All rights reserved.
10
 * @license   BSD License
11
 */
12
class CashOnDelivery extends Option
13
{
14
    /**
15
     * @var float
16
     */
17
    private $amount;
18
19
    /**
20
     * @var string
21
     */
22
    private $iban;
23
24
    /**
25
     * @var string
26
     */
27
    private $bic;
28
29
    /**
30
     * @param float $amount
31
     */
32 2
    public function setAmount($amount)
33
    {
34 2
        $this->amount = $amount;
35 2
    }
36
37
    /**
38
     * @return float
39
     */
40 2
    public function getAmount()
41
    {
42 2
        return $this->amount;
43
    }
44
45
    /**
46
     * @param string $bic
47
     */
48 2
    public function setBic($bic)
49
    {
50 2
        $this->bic = $bic;
51 2
    }
52
53
    /**
54
     * @return string
55
     */
56 2
    public function getBic()
57
    {
58 2
        return $this->bic;
59
    }
60
61
    /**
62
     * @param string $iban
63
     */
64 2
    public function setIban($iban)
65
    {
66 2
        $this->iban = $iban;
67 2
    }
68
69
    /**
70
     * @return string
71
     */
72 2
    public function getIban()
73
    {
74 2
        return $this->iban;
75
    }
76
77
    /**
78
     * @param float  $amount
79
     * @param string $iban
80
     * @param string $bic
81
     */
82 2
    public function __construct($amount, $iban, $bic)
83
    {
84 2
        $this->setAmount($amount);
85 2
        $this->setIban($iban);
86 2
        $this->setBic($bic);
87 2
    }
88
89
    /**
90
     * Return the object as an array for usage in the XML
91
     *
92
     * @param  \DomDocument $document
93
     * @param  string       $prefix
94
     * @return \DomElement
95
     */
96 2
    public function toXML(\DOMDocument $document, $prefix = 'common')
97
    {
98 2
        $tagName = 'cod';
99 2
        if ($prefix !== null) {
100 2
            $tagName = $prefix . ':' . $tagName;
101 2
        }
102
103 2
        $cod = $document->createElement($tagName);
104
105 2
        if ($this->getAmount() !== null) {
106 2
            $tagName = 'codAmount';
107 2
            if ($prefix !== null) {
108 2
                $tagName = $prefix . ':' . $tagName;
109 2
            }
110 2
            $cod->appendChild(
111 2
                $document->createElement(
112 2
                    $tagName,
113 2
                    $this->getAmount()
114 2
                )
115 2
            );
116 2
        }
117 2 View Code Duplication
        if ($this->getIban() !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
118 2
            $tagName = 'iban';
119 2
            if ($prefix !== null) {
120 2
                $tagName = $prefix . ':' . $tagName;
121 2
            }
122 2
            $cod->appendChild(
123 2
                $document->createElement(
124 2
                    $tagName,
125 2
                    $this->getIban()
126 2
                )
127 2
            );
128 2
        }
129 2 View Code Duplication
        if ($this->getBic() !== null) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
130 2
            $tagName = 'bic';
131 2
            if ($prefix !== null) {
132 2
                $tagName = $prefix . ':' . $tagName;
133 2
            }
134 2
            $cod->appendChild(
135 2
                $document->createElement(
136 2
                    $tagName,
137 2
                    $this->getBic()
138 2
                )
139 2
            );
140 2
        }
141
142 2
        return $cod;
143
    }
144
}
145