RefundResponse   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 61
rs 10
wmc 9

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getMessage() 0 3 1
A getCode() 0 6 1
A isPending() 0 7 3
A getTransactionReference() 0 3 1
A isSuccessful() 0 7 3
1
<?php
2
3
namespace Omnipay\Worldline\Message;
4
5
use Omnipay\Common\Message\AbstractResponse;
6
7
/**
8
 * Worldline Refund Response
9
 */
10
class RefundResponse extends AbstractResponse
11
{
12
    /**
13
     * Is the response pending success or failure?
14
     *
15
     * @return boolean
16
     */
17
    public function isPending()
18
    {
19
        if (empty($this->data) || isset($this->data->errorId)) {
20
            return false;
21
        }
22
23
        return $this->data->status == 'REFUND_REQUESTED';
24
    }
25
26
    /**
27
     * Is the response successful?
28
     *
29
     * @return boolean
30
     */
31
    public function isSuccessful()
32
    {
33
        if (empty($this->data) || isset($this->data->errorId)) {
34
            return false;
35
        }
36
37
        return $this->data->status == 'REFUNDED';
38
    }
39
40
    /**
41
     * Numeric status code (also in back office / report files)
42
     *
43
     * @return null|string
44
     */
45
    public function getCode()
46
    {
47
        return $this->data->statusOutput->statusCode
48
            ?? $this->data->refundResult->statusOutput->statusCode
49
            ?? $this->data->errors[0]->errorCode
50
            ?? null;
51
    }
52
53
    /**
54
     * Get the authorisation code if available.
55
     *
56
     * @return null|string
57
     */
58
    public function getTransactionReference()
59
    {
60
        return $this->data->id ?? null;
61
    }
62
63
    /**
64
     * Get the merchant response message if available.
65
     *
66
     * @return null|string
67
     */
68
    public function getMessage()
69
    {
70
        return $this->data->status ?? $this->data->errorId ?? null;
71
    }
72
}
73