Passed
Push — master ( 804fca...223e27 )
by John
07:23
created

AuthnetJsonResponse::__set()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 1
b 0
f 1
1
<?php
0 ignored issues
show
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "AuthnetJsonResponse.php" doesn't match the expected filename "authnetjsonresponse.php"
Loading history...
2
3
declare(strict_types=1);
4
5
/**
0 ignored issues
show
Coding Style introduced by
Block comments must be started with /*
Loading history...
6
 * This file is part of the AuthnetJSON package.
7
 *
8
 * (c) John Conde <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Authnetjson;
15
16
use Authnetjson\Exception\AuthnetCannotSetParamsException;
17
use Authnetjson\Exception\AuthnetInvalidJsonException;
18
use Authnetjson\Exception\AuthnetTransactionResponseCallException;
19
20
/**
21
 * Adapter for the Authorize.Net JSON API
22
 *
23
 * @package   AuthnetJSON
24
 * @author    John Conde <[email protected]>
25
 * @copyright John Conde <[email protected]>
26
 * @license   http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0
27
 * @link      https://github.com/stymiee/authnetjson
28
 * @see       https://developer.authorize.net/api/reference/
29
 *
30
 * @property object $messages
31
 * @property string $directResponse
32
 * @property string $validationDirectResponseList
33
 * @property object $transactionResponse
34
 *
35
 * @method null createTransactionRequest(array $array)
36
 * @method null sendCustomerTransactionReceiptRequest(array $array)
37
 * @method null ARBCancelSubscriptionRequest(array $array)
38
 * @method null ARBCreateSubscriptionRequest(array $array)
39
 * @method null ARBGetSubscriptionStatusRequest(array $array)
40
 * @method null ARBUpdateSubscriptionRequest(array $array)
41
 * @method null createCustomerPaymentProfileRequest(array $array)
42
 * @method null createCustomerProfileRequest(array $array)
43
 * @method null createCustomerProfileTransactionRequest_authCapture(array $array)
44
 * @method null createCustomerProfileTransactionRequest_authOnly(array $array)
45
 * @method null createCustomerProfileTransactionRequest_captureOnly(array $array)
46
 * @method null createCustomerProfileTransactionRequest_priorAuthCapture(array $array)
47
 * @method null createCustomerProfileTransactionRequest_refund(array $array)
48
 * @method null createCustomerProfileTransactionRequest_void(array $array)
49
 * @method null createCustomerShippingAddressRequest(array $array)
50
 * @method null deleteCustomerPaymentProfileRequest(array $array)
51
 * @method null deleteCustomerProfileRequest(array $array)
52
 * @method null deleteCustomerShippingAddressRequest(array $array)
53
 * @method null getCustomerPaymentProfileRequest(array $array)
54
 * @method null getCustomerProfileIdsRequest(array $array)
55
 * @method null getCustomerProfileRequest(array $array)
56
 * @method null getCustomerShippingAddressRequest(array $array)
57
 * @method null getHostedProfilePageRequest(array $array)
58
 * @method null updateCustomerPaymentProfileRequest(array $array)
59
 * @method null updateCustomerProfileRequest(array $array)
60
 * @method null updateCustomerShippingAddressRequest(array $array)
61
 * @method null updateSplitTenderGroupRequest(array $array)
62
 * @method null validateCustomerPaymentProfileRequest(array $array)
63
 * @method null getBatchStatisticsRequest(array $array)
64
 * @method null getSettledBatchListRequest(array $array)
65
 * @method null getTransactionDetailsRequest(array $array)
66
 * @method null getTransactionListRequest(array $array)
67
 * @method null getUnsettledTransactionListRequest(array $array)
68
 */
69
class AuthnetJsonResponse
70
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class AuthnetJsonResponse
Loading history...
71
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
72
     * @const Indicates the status code of an approved transaction
73
     */
74
    public const STATUS_APPROVED = 1;
75
76
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
77
     * @const Indicates the status code of a declined transaction
78
     */
79
    public const STATUS_DECLINED = 2;
80
81
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
82
     * @const Indicates the status code of a transaction which has encountered an error
83
     */
84
    public const STATUS_ERROR = 3;
85
86
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
87
     * @const Indicates the status code of a transaction held for review
88
     */
89
    public const STATUS_HELD = 4;
90
91
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
92
     * @const Indicates the status code of a transaction held for review
93
     */
94
    public const STATUS_PAYPAL_NEED_CONSENT = 5;
95
96
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
97
     * @var object  SimpleXML object representing the API response
98
     */
99
    private $response;
0 ignored issues
show
Coding Style introduced by
Private member variable "response" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "response" must be prefixed with an underscore
Loading history...
100
101
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
102
     * @var string  JSON string that is the response sent by Authorize.Net
103
     */
104
    private $responseJson;
0 ignored issues
show
Coding Style introduced by
Private member variable "responseJson" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "responseJson" must be prefixed with an underscore
Loading history...
105
106
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
107
     * @var object  TransactionResponse
108
     */
109
    private $transactionInfo;
0 ignored issues
show
Coding Style introduced by
Private member variable "transactionInfo" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "transactionInfo" must be prefixed with an underscore
Loading history...
110
111
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
112
     * @var array  TransactionResponse
113
     */
114
    private $transactionInfoArray;
0 ignored issues
show
Coding Style introduced by
Private member variable "transactionInfoArray" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "transactionInfoArray" must be prefixed with an underscore
Loading history...
115
116
    /**
117
     * Creates the response object with the response json returned from the API call
118
     *
119
     * @param string $responseJson Response from Authorize.Net
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
120
     * @throws AuthnetInvalidJsonException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
introduced by
Comment missing for @throws tag in function comment
Loading history...
121
     */
122 4
    public function __construct(string $responseJson)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
123
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
124 4
        $this->responseJson = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $responseJson);
125 4
        if (($this->response = json_decode($this->responseJson, false)) === null) {
0 ignored issues
show
Coding Style introduced by
Variable assignment found within a condition. Did you mean to do a comparison ?
Loading history...
Coding Style introduced by
Assignments must be the first block of code on a line
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of false please use FALSE.
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
126 1
            throw new AuthnetInvalidJsonException('Invalid JSON returned by the API');
127
        }
128
129 3
        if ($this->directResponse
130 2
            || $this->validationDirectResponseList
131 3
            || isset($this->response->validationDirectResponse)
132
        ) {
133 3
            $response = $this->directResponse ?:
0 ignored issues
show
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
Coding Style introduced by
Expected 1 space after ":"; newline found
Loading history...
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
134 2
                $this->validationDirectResponseList ?:
0 ignored issues
show
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
Coding Style introduced by
Expected 1 space after ":"; newline found
Loading history...
135 3
                $this->response->validationDirectResponse;
136 3
            if (is_array($response)) {
137 1
                $this->transactionInfoArray = array_map(
138
                    static function ($r) {
139 1
                        return new TransactionResponse($r);
140 1
                    },
141 1
                    $response
142
                );
143
            } else {
144 2
                $this->transactionInfo = new TransactionResponse($response);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
145 2
                $this->transactionInfoArray = [$this->transactionInfo];
146
            }
147
        }
148 3
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __construct()
Loading history...
149
150
    /**
151
     * Outputs the response JSON in a human-readable format
152
     *
153
     * @return string  HTML table containing debugging information
154
     */
155 1
    public function __toString()
156
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
157 1
        $output = '<table id="authnet-response">' . "\n";
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
158 1
        $output .= '<caption>Authorize.Net Response</caption>' . "\n";
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
159 1
        $output .= '<tr><th colspan="2"><b>Response JSON</b></th></tr>' . "\n";
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
160 1
        $output .= '<tr><td colspan="2"><pre>' . "\n";
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
161 1
        $output .= $this->responseJson . "\n";
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
162 1
        $output .= '</pre></td></tr>' . "\n";
0 ignored issues
show
Coding Style introduced by
Concat operator must not be surrounded by spaces
Loading history...
163 1
        $output .= '</table>';
164
165 1
        return $output;
166
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __toString()
Loading history...
167
168
    /**
169
     * Gets a response variable from the API response
170
     *
171
     * @param string $key Name of the response key to be retrieved if it exists
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
172
     * @return string requested variable from the API call response
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
173
     */
174 2
    public function __get(string $key)
175
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
176 2
        return $this->response->{$key} ?? null;
0 ignored issues
show
Coding Style introduced by
Operation must be bracketed
Loading history...
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of null please use NULL.
Loading history...
177
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __get()
Loading history...
178
179
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
Documentation introduced by
Doc comment for parameter "$key" missing
Loading history...
Documentation introduced by
Doc comment for parameter "$value" missing
Loading history...
180
     * @throws AuthnetCannotSetParamsException
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
181
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
182 1
    public function __set(string $key, $value)
0 ignored issues
show
Coding Style introduced by
The method parameter $key is never used
Loading history...
Coding Style introduced by
The method parameter $value is never used
Loading history...
183
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
184 1
        throw new AuthnetCannotSetParamsException(sprintf('You cannot set parameters directly in %s.', __CLASS__));
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 115 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
185
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __set()
Loading history...
186
187
    /**
188
     * Checks if a value exists in the response JSON object
189
     *
190
     * @param string $key Name of the response key to check existence of
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
191
     * @return bool
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
192
     */
193 1
    public function __isset(string $key): bool
194
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
195 1
        return isset($this->response->{$key});
196
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end __isset()
Loading history...
197
198
    /**
199
     * Checks if the API call is not in an error state
200
     *
201
     * @return bool    Whether the transaction was in a successful state
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
202
     */
203 2
    public function isSuccessful(): bool
204
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
205 2
        return strtolower($this->messages->resultCode) === 'ok';
206
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end isSuccessful()
Loading history...
207
208
    /**
209
     * Checks if the API is reporting an error with the API call
210
     *
211
     * @return bool    Whether the transaction was in an error state
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
212
     */
213 2
    public function isError(): bool
214
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
215 2
        return strtolower($this->messages->resultCode) === 'error';
216
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end isError()
Loading history...
217
218
    /**
219
     * Checks if a transaction was approved
220
     *
221
     * @return bool     true if the transaction is approved
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
222
     */
223 1
    public function isApproved(): bool
224
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
225 1
        return $this->isSuccessful() && $this->checkTransactionStatus(self::STATUS_APPROVED);
0 ignored issues
show
Coding Style introduced by
Boolean operators are not allowed outside of control structure conditions
Loading history...
226
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end isApproved()
Loading history...
227
228
    /**
229
     * Checks if a transaction was completed using a prepaid card
230
     *
231
     * @return bool     true if the transaction was completed using a prepaid card
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
232
     */
233 1
    public function isPrePaidCard(): bool
234
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
235 1
        return isset($this->transactionResponse->prePaidCard);
236
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end isPrePaidCard()
Loading history...
237
238
    /**
239
     * Checks if a transaction was declined
240
     *
241
     * @return bool     true if the transaction is declined
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
242
     */
243 1
    public function isDeclined(): bool
244
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
245 1
        return $this->isSuccessful() && $this->checkTransactionStatus(self::STATUS_DECLINED);
0 ignored issues
show
Coding Style introduced by
Boolean operators are not allowed outside of control structure conditions
Loading history...
246
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end isDeclined()
Loading history...
247
248
    /**
249
     * Check to see if the ResponseCode matches the expected value
250
     *
251
     * @param int $status
0 ignored issues
show
Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
252
     * @return bool Check to see if the ResponseCode matches the expected value
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
253
     */
254 2
    protected function checkTransactionStatus(int $status): bool
255
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
256 2
        if ($this->transactionInfo instanceof TransactionResponse) {
257 1
            $match = (int)$this->transactionInfo->getTransactionResponseField('ResponseCode') === $status;
0 ignored issues
show
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
Coding Style introduced by
Expected 1 space(s) after cast statement; 0 found
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 106 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
258
        } else {
259 1
            $match = (int)$this->transactionResponse->responseCode === $status;
0 ignored issues
show
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
Coding Style introduced by
Expected 1 space(s) after cast statement; 0 found
Loading history...
260
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
261 2
        return $match;
262
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected //end checkTransactionStatus()
Loading history...
263
264
    /**
265
     * Gets the transaction response field for AIM and CIM transactions.
266
     *
267
     * @param mixed $field Name or key of the transaction field to be retrieved
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
268
     * @return null|string Transaction field to be retrieved
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
269
     * @throws AuthnetTransactionResponseCallException
0 ignored issues
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
introduced by
Comment missing for @throws tag in function comment
Loading history...
270
     */
271 2
    public function getTransactionResponseField($field): ?string
272
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
273 2
        if ($this->transactionInfo instanceof TransactionResponse) {
274 1
            return $this->transactionInfo->getTransactionResponseField($field);
275
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
276 1
        throw new AuthnetTransactionResponseCallException('This API call does not have any transaction response data');
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 119 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
277
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getTransactionResponseField()
Loading history...
278
279
    /**
280
     * Returns the results of a test charge for each payment account provided when created a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 109 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
281
     *
282
     * @return array
283
     */
284 1
    public function getTransactionResponses(): array
285
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
286 1
        return $this->transactionInfoArray;
287
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getTransactionResponses()
Loading history...
288
289
    /**
290
     * Gets the transaction response from Authorize.Net in JSON format for logging purposes
291
     *
292
     * @return string transaction response from Authorize.Net in JSON format
293
     */
294 1
    public function getRawResponse(): string
295
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
296 1
        return $this->responseJson;
297
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getRawResponse()
Loading history...
298
299
    /**
300
     * An alias of self::getErrorText()
301
     *
302
     * @return string Error response from Authorize.Net
303
     */
304 1
    public function getErrorMessage(): string
305
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
306 1
        return $this->getErrorText();
307
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getErrorMessage()
Loading history...
308
309
    /**
310
     * If an error has occurred, returns the error message
311
     *
312
     * @return string Error response from Authorize.Net
313
     */
314 2
    public function getErrorText(): string
315
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
316 2
        return $this->getError('text');
317
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getErrorText()
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
318
319
    /**
320
     * If an error has occurred, returns the error message
321
     *
322
     * @return string Error response from Authorize.Net
323
     */
324 2
    public function getErrorCode(): string
325
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
326 2
        return $this->getError('code');
327
    }
0 ignored issues
show
Coding Style introduced by
Expected //end getErrorCode()
Loading history...
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
328
329
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
330
     * @param string $type Whether to get the error code or text
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
331
     * @return string
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
332
     */
333 2
    private function getError(string $type): string
0 ignored issues
show
Coding Style introduced by
Private method name "AuthnetJsonResponse::getError" must be prefixed with an underscore
Loading history...
334
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
335 2
        $msg = '';
336 2
        if ($this->isError()) {
337 2
            $prop = sprintf('error%s', ucfirst($type));
338 2
            $msg = $this->messages->message[0]->{$type};
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
339 2
            if (@$this->transactionResponse->errors[0]->{$prop}) {
0 ignored issues
show
Coding Style introduced by
Silencing errors is discouraged; found: @$this->transactionResponse...
Loading history...
340 1
                $msg = $this->transactionResponse->errors[0]->{$prop};
341
            }
342
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
343 2
        return $msg;
344
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected //end getError()
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
345
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
346