Passed
Push — master ( da7868...61e5a6 )
by Kiet
53s queued 11s
created

isSuccessful()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 2
eloc 3
c 2
b 1
f 0
nc 2
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 2
rs 10
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
class CompleteAuthoriseAndCaptureResponse extends AbstractResponse
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14 2
    public function isSuccessful(): bool
15
    {
16 2
        return isset($this->data['status']) && in_array($this->data['status'], [
17 2
            self::RESPONSE_STATUS_COMPLETED,
18 2
            self::RESPONSE_STATUS_SETTLED,
19
        ]);
20
    }
21
22
    /**
23
     * {@inheritdoc}
24
     *
25
     * In case there is no status 'cancelled' available in the response (yet), check if there is statusCode in the
26
     * queryString. Icepay calls a postback to the completeUrl with data of the payment transaction as queryString.
27
     */
28 1
    public function isCancelled(): bool
29
    {
30 1
        return isset($this->data['status']) && $this->data['status'] === self::RESPONSE_STATUS_CANCELLED
31 1
            || $this->request->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

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