Transaction::isUnderContest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace PHPSC\PagSeguro\Purchases\Transactions;
3
4
use DateTime;
5
use PHPSC\PagSeguro\Items\ItemCollection;
6
use PHPSC\PagSeguro\Purchases\Details;
7
use PHPSC\PagSeguro\Shipping\Shipping;
8
9
/**
10
 * @author Luís Otávio Cobucci Oblonczyk <[email protected]>
11
 */
12
class Transaction
13
{
14
    /**
15
     * @var int
16
     */
17
    const WAITING_PAYMENT = '1';
18
19
    /**
20
     * @var int
21
     */
22
    const UNDER_ANALYSIS = '2';
23
24
    /**
25
     * @var int
26
     */
27
    const PAID = '3';
28
29
    /**
30
     * @var int
31
     */
32
    const AVAILABLE = '4';
33
34
    /**
35
     * @var int
36
     */
37
    const UNDER_CONTEST = '5';
38
39
    /**
40
     * @var int
41
     */
42
    const RETURNED = '6';
43
44
    /**
45
     * @var int
46
     */
47
    const CANCELLED = '7';
48
49
    /**
50
     * @var Details
51
     */
52
    private $details;
53
54
    /**
55
     * @var Payment
56
     */
57
    private $payment;
58
59
    /**
60
     * @var int
61
     */
62
    private $type;
63
64
    /**
65
     * @var ItemCollection
66
     */
67
    private $items;
68
69
    /**
70
     * @var Shipping
71
     */
72
    private $shipping;
73
74
    /**
75
     * @param Details $details
76
     * @param Payment $payment
77
     * @param int $type
78
     * @param ItemCollection $items
79
     * @param Shipping $shipping
80
     */
81 14
    public function __construct(
82
        Details $details,
83
        Payment $payment,
84
        $type,
85
        ItemCollection $items,
86
        Shipping $shipping = null
87
    ) {
88 14
        $this->details = $details;
89 14
        $this->payment = $payment;
90 14
        $this->type = $type;
91 14
        $this->items = $items;
92 14
        $this->shipping = $shipping;
93 14
    }
94
95
    /**
96
     * @return Details
97
     */
98 1
    public function getDetails()
99
    {
100 1
        return $this->details;
101
    }
102
103
    /**
104
     * @return number
105
     */
106 1
    public function getType()
107
    {
108 1
        return $this->type;
109
    }
110
111
    /**
112
     * @return Payment
113
     */
114 1
    public function getPayment()
115
    {
116 1
        return $this->payment;
117
    }
118
119
    /**
120
     * @return ItemCollection
121
     */
122 1
    public function getItems()
123
    {
124 1
        return $this->items;
125
    }
126
127
    /**
128
     * @return Shipping
129
     */
130 1
    public function getShipping()
131
    {
132 1
        return $this->shipping;
133
    }
134
135
    /**
136
     * @return boolean
137
     */
138 1
    public function isWaitingPayment()
139
    {
140 1
        return $this->details->getStatus() === static::WAITING_PAYMENT;
141
    }
142
143
    /**
144
     * @return boolean
145
     */
146 1
    public function isUnderAnalysis()
147
    {
148 1
        return $this->details->getStatus() === static::UNDER_ANALYSIS;
149
    }
150
151
    /**
152
     * @return boolean
153
     */
154 1
    public function isPaid()
155
    {
156 1
        return $this->details->getStatus() === static::PAID;
157
    }
158
159
    /**
160
     * @return boolean
161
     */
162 1
    public function isAvailable()
163
    {
164 1
        return $this->details->getStatus() === static::AVAILABLE;
165
    }
166
167
    /**
168
     * @return boolean
169
     */
170 1
    public function isUnderContest()
171
    {
172 1
        return $this->details->getStatus() === static::UNDER_CONTEST;
173
    }
174
175
    /**
176
     * @return boolean
177
     */
178 1
    public function isReturned()
179
    {
180 1
        return $this->details->getStatus() === static::RETURNED;
181
    }
182
183
    /**
184
     * @return boolean
185
     */
186 1
    public function isCancelled()
187
    {
188 1
        return $this->details->getStatus() === static::CANCELLED;
189
    }
190
}
191