Passed
Pull Request — master (#63)
by
unknown
02:04
created

Order::isShippingAddressRequired()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
namespace PHPSC\PagSeguro\Requests\Checkout;
3
4
use JMS\Serializer\Annotation as Serializer;
5
use PHPSC\PagSeguro\Items\ItemCollection;
6
use PHPSC\PagSeguro\Items\Items;
7
use PHPSC\PagSeguro\SerializerTrait;
8
use PHPSC\PagSeguro\Shipping\Shipping;
9
10
/**
11
 * @Serializer\AccessType("public_method")
12
 * @Serializer\ReadOnly
13
 * @Serializer\XmlRoot("order")
14
 *
15
 * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
16
 */
17
class Order
18
{
19
    use SerializerTrait;
20
21
    /**
22
     * @Serializer\XmlElement(cdata=false)
23
     *
24
     * @var string
25
     */
26
    private $currency;
27
28
    /**
29
     * @Serializer\SerializedName("items")
30
     * @Serializer\Type("ArrayCollection<PHPSC\PagSeguro\Items\Item>")
31
     * @Serializer\XmlList(entry="item")
32
     *
33
     * @var ItemCollection
34
     */
35
    private $items;
36
37
    /**
38
     * @Serializer\XmlElement(cdata=false)
39
     *
40
     * @var string
41
     */
42
    private $reference;
43
44
    /**
45
     * @Serializer\XmlElement(cdata=true)
46
     * @Serializer\Type("boolean")
47
     *
48
     * @var bool
49
     */
50
    private $shippingAddressRequired;
51
52
    /**
53
     * @Serializer\Type("PHPSC\PagSeguro\Shipping\Shipping")
54
     *
55
     * @var Shipping
56
     */
57
    private $shipping;
58
59
    /**
60
     * @Serializer\XmlElement(cdata=false)
61
     *
62
     * @var float
63
     */
64
    private $extraAmount;
65
66
    /**
67
     * @param ItemCollection $items
68
     */
69 38
    public function __construct(ItemCollection $items = null)
70
    {
71 38
        $this->items    = $items ? : new Items();
72 38
        $this->currency = 'BRL';
73 38
    }
74
75
    /**
76
     * @return string
77
     */
78 5
    public function getCurrency()
79
    {
80 5
        return $this->currency;
81
    }
82
83
    /**
84
     * @return ItemCollection
85
     */
86 6
    public function getItems()
87
    {
88 6
        return $this->items;
89
    }
90
91
    /**
92
     * @return string
93
     */
94 5
    public function getReference()
95
    {
96 5
        return $this->reference;
97
    }
98
99
    /**
100
     * @param string $reference
101
     */
102 4
    public function setReference($reference)
103
    {
104 4
        $this->reference = $reference;
105 4
    }
106
107
    /**
108
     * @return bool
109
     */
110 5
    public function isShippingAddressRequired()
111
    {
112 5
        return $this->shippingAddressRequired;
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118 2
    public function notRequireShippingAddress()
119
    {
120 2
        $this->shippingAddressRequired = false;
121 2
    }
122
123
    /**
124
     * @return Shipping
125
     */
126 5
    public function getShipping()
127
    {
128 5
        return $this->shipping;
129
    }
130
131
    /**
132
     * @param Shipping $shipping
133
     */
134 4
    public function setShipping(Shipping $shipping)
135
    {
136 4
        $this->shipping = $shipping;
137 4
    }
138
139
    /**
140
     * @return float
141
     */
142 5
    public function getExtraAmount()
143
    {
144 5
        return $this->formatAmount($this->extraAmount);
145
    }
146
147
    /**
148
     * @param float $extraAmount
149
     */
150 3
    public function setExtraAmount($extraAmount)
151
    {
152 3
        $this->extraAmount = $extraAmount;
153 3
    }
154
}
155