TransactionStatusResponse   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 8
Bugs 0 Features 1
Metric Value
eloc 8
c 8
b 0
f 1
dl 0
loc 51
ccs 10
cts 12
cp 0.8333
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A isSuccessful() 0 3 1
A getTransactionReference() 0 3 2
A isCancelled() 0 3 2
A getCode() 0 3 1
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