Response::getMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Larium\Pay;
6
7
class Response
8
{
9
    /**
10
     * @var bool
11
     */
12
    private $success;
13
14
    /**
15
     * @var string
16
     */
17
    private $message;
18
19
    /**
20
     * @var string
21
     */
22
    private $transactionId;
23
24
    /**
25
     * @var string|int
26
     */
27
    private $errorCode;
28
29
    /**
30
     * @var string
31
     */
32
    private $responseCode;
33
34
    /**
35
     * @var array
36
     */
37
    private $payload;
38
39
    /**
40
     * @var string
41
     */
42
    private $rawRequest;
43
44
    /**
45
     * @var string
46
     */
47
    private $rawResponse;
48
49
    /**
50
     * @param bool $success
51
     * @param string $message
52
     * @param string $transactionId
53
     * @param string $errorCode
54
     * @param string $responseCode
55
     * @param array $payload
56
     * @param string $rawRequest
57
     * @param string $rawResponse
58
     */
59 1
    public function __construct(
60
        $success,
61
        $message,
62
        $transactionId,
63
        $errorCode = '0',
64
        $responseCode = '00',
65
        array $payload = [],
66
        $rawResponse = null,
67
        $rawRequest = null
68
    ) {
69 1
        $this->success = $success;
70 1
        $this->message = $message;
71 1
        $this->transactionId = $transactionId;
72 1
        $this->errorCode = $errorCode;
73 1
        $this->responseCode = $responseCode;
74 1
        $this->payload = $payload;
75 1
        $this->rawRequest = $rawRequest;
76 1
        $this->rawResponse = $rawResponse;
77
    }
78
79
    /**
80
     * Returns whether response is success or not.
81
     *
82
     * @return bool
83
     */
84
    public function isSuccess()
85
    {
86
        return $this->success;
87
    }
88
89
    /**
90
     * Returns the unique transaction id from gateway.
91
     *
92
     * @return string
93
     */
94
    public function getTransactionId()
95
    {
96
        return $this->transactionId;
97
    }
98
99
    /**
100
     * Returns the error code from gateway, if exists.
101
     *
102
     * @return string|int
103
     */
104
    public function getErrorCode()
105
    {
106
        return $this->errorCode;
107
    }
108
109
    /**
110
     * Returns a human readable message for current transaction response,
111
     * either on success or failed transactions.
112
     *
113
     * @return string
114
     */
115
    public function getMessage()
116
    {
117
        return $this->message;
118
    }
119
120
    /**
121
     * Returns the credit card response code from gateway, if exits.
122
     *
123
     * This must be the {@link [https://en.wikipedia.org/wiki/ISO_8583#Response_code][ISO 8583]} ISO 8583 response code.
124
     *
125
     * @return string
126
     */
127
    public function getResponseCode()
128
    {
129
        return $this->responseCode;
130
    }
131
132
    /**
133
     * Returns any gateway response element as an associative array.
134
     * Array may contain nested elements.
135
     *
136
     * @return array
137
     */
138
    public function getPayload()
139
    {
140
        return $this->payload;
141
    }
142
143
    public function getRawRequest()
144
    {
145
        return $this->rawRequest;
146
    }
147
148
    public function getRawResponse()
149
    {
150
        return $this->rawResponse;
151
    }
152
}
153