TransactionStatusResponse::isCancelled()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 1
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Omnipay\IcepayPayments\Message;
4
5
use Omnipay\Common\Message\RequestInterface;
6
7
/**
8
 * The response after getting the transaction status at Icepay.
9
 * For this response, we check the response (statusCode) of the payment transaction at Icepay.
10
 */
11
class TransactionStatusResponse extends AbstractResponse
12
{
13
    /**
14
     * @var int
15
     */
16
    private $statusCode;
17
18
    /**
19
     * TransactionStatusResponse constructor.
20
     *
21
     * @param RequestInterface $request
22
     * @param mixed            $data
23
     * @param int              $statusCode
24
     */
25 4
    public function __construct(RequestInterface $request, $data, int $statusCode)
26
    {
27 4
        parent::__construct($request, $data);
28
29 4
        $this->statusCode = $statusCode;
30 4
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function getCode()
36
    {
37
        return $this->statusCode;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 2
    public function isSuccessful(): bool
44
    {
45 2
        return $this->statusCode === 200;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 1
    public function isCancelled(): bool
52
    {
53 1
        return isset($this->data['status']) && $this->data['status'] === self::RESPONSE_STATUS_CANCELLED;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 1
    public function getTransactionReference(): ?string
60
    {
61 1
        return isset($this->data['id']) ? $this->data['id'] : $this->request->getTransactionReference();
62
    }
63
}
64