Completed
Pull Request — master (#63)
by
unknown
01:50
created

Order::withoutShippingAddress()   A

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 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 39
    public function __construct(ItemCollection $items = null)
70
    {
71 39
        $this->items    = $items ? : new Items();
72 39
        $this->currency = 'BRL';
73 39
        $this->shippingAddressRequired = true;
74 39
    }
75
76
    /**
77
     * @return string
78
     */
79 5
    public function getCurrency()
80
    {
81 5
        return $this->currency;
82
    }
83
84
    /**
85
     * @return ItemCollection
86
     */
87 6
    public function getItems()
88
    {
89 6
        return $this->items;
90
    }
91
92
    /**
93
     * @return string
94
     */
95 5
    public function getReference()
96
    {
97 5
        return $this->reference;
98
    }
99
100
    /**
101
     * @param string $reference
102
     */
103 4
    public function setReference($reference)
104
    {
105 4
        $this->reference = $reference;
106 4
    }
107
108
    /**
109
     * @return bool
110
     */
111 6
    public function isShippingAddressRequired()
112
    {
113 6
        return $this->shippingAddressRequired;
114
    }
115
116
    /**
117
     * {@inheritdoc}
118
     */
119 2
    public function withoutShippingAddress()
120
    {
121 2
        $this->shippingAddressRequired = false;
122 2
    }
123
124
    /**
125
     * @return Shipping
126
     */
127 5
    public function getShipping()
128
    {
129 5
        return $this->shipping;
130
    }
131
132
    /**
133
     * @param Shipping $shipping
134
     */
135 4
    public function setShipping(Shipping $shipping)
136
    {
137 4
        $this->shipping = $shipping;
138 4
    }
139
140
    /**
141
     * @return float
142
     */
143 5
    public function getExtraAmount()
144
    {
145 5
        return $this->formatAmount($this->extraAmount);
146
    }
147
148
    /**
149
     * @param float $extraAmount
150
     */
151 3
    public function setExtraAmount($extraAmount)
152
    {
153 3
        $this->extraAmount = $extraAmount;
154 3
    }
155
}
156