Passed
Push — splits-transaction-status-to-c... ( 66d580...e5df75 )
by Kiet
01:56
created

CompleteAuthoriseAndCaptureResponse   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 7
c 3
b 1
f 0
dl 0
loc 31
ccs 9
cts 9
cp 1
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isSuccessful() 0 5 2
A isCancelled() 0 4 3
A getTransactionReference() 0 3 1
1
<?php
2
3
namespace Omnipay\IcepayPayments\Message;
4
5
/**
6
 * The response after complete authorise and capture request.
7
 * For this response, we explicitly check what the status is of the payment transaction at Icepay.
8
 *
9
 * @see http://docs2.icepay.com/payment-process/transaction-status-flow/transaction-statuses/
10
 */
11
class CompleteAuthoriseAndCaptureResponse extends AbstractResponse
12
{
13
    /**
14
     * {@inheritdoc}
15
     */
16 2
    public function isSuccessful(): bool
17
    {
18 2
        return isset($this->data['status']) && in_array($this->data['status'], [
19 2
            self::RESPONSE_STATUS_COMPLETED,
20 2
            self::RESPONSE_STATUS_SETTLED,
21
        ]);
22
    }
23
24
    /**
25
     * {@inheritdoc}
26
     *
27
     * In case there is no status 'cancelled' available yet, look up for a statusCode querystring in the HttpRequest.
28
     * Icepay will redirect you to the complete page with the statusCode query string.
29
     */
30 1
    public function isCancelled(): bool
31
    {
32 1
        return isset($this->data['status']) && $this->data['status'] === self::RESPONSE_STATUS_CANCELLED ||
33 1
            $this->getRequest()->getHttpRequest()->get('statusCode') === self::RESPONSE_STATUS_CANCELLED;
0 ignored issues
show
Bug introduced by
The method getHttpRequest() does not exist on Omnipay\Common\Message\RequestInterface. It seems like you code against a sub-type of Omnipay\Common\Message\RequestInterface such as Omnipay\IcepayPayments\M...horiseAndCaptureRequest. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
            $this->getRequest()->/** @scrutinizer ignore-call */ getHttpRequest()->get('statusCode') === self::RESPONSE_STATUS_CANCELLED;
Loading history...
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    public function getTransactionReference(): ?string
40
    {
41 1
        return $this->request->getTransactionReference();
42
    }
43
}
44