Test Failed
Pull Request — master (#10)
by Kiet
03:33 queued 01:50
created

TransactionStatusResponse::isSuccessful()   A

Complexity

Conditions 4
Paths 5

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 4.128

Importance

Changes 4
Bugs 0 Features 1
Metric Value
cc 4
eloc 4
c 4
b 0
f 1
nc 5
nop 0
dl 0
loc 6
ccs 4
cts 5
cp 0.8
crap 4.128
rs 10
1
<?php
2
3
namespace Omnipay\IcepayPayments\Message;
4
5
/**
6
 * The response after getting the transaction status at Icepay.
7
 */
8
class TransactionStatusResponse extends AbstractResponse
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13 2
    public function isSuccessful(): bool
14
    {
15 2
        return (isset($this->data['status']) && in_array($this->data['status'], [
16
            self::RESPONSE_STATUS_COMPLETED,
17 2
            self::RESPONSE_STATUS_SETTLED,
18 2
        ])) && (isset($this->data['statusCode']) && $this->data['statusCode'] === 200);
19
    }
20
21
    /**
22
     * {@inheritdoc}
23
     */
24 1
    public function isCancelled(): bool
25
    {
26 1
        return parent::isCancelled() || $this->data['statusCode'] === self::RESPONSE_STATUS_CANCELLED;
27
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getTransactionReference(): ?string
33
    {
34
        return $this->request->getTransactionReference();
35
    }
36
}
37