Passed
Branch master (1abeda)
by John
05:13 queued 02:38
created

AuthnetJsonResponse::isPrePaidCard()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 JohnConde\Authnet;
15
16
/**
17
 * Adapter for the Authorize.Net JSON API
18
 *
19
 * @package     AuthnetJSON
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 3 spaces but found 5
Loading history...
20
 * @author      John Conde <[email protected]>
0 ignored issues
show
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 4 spaces but found 6
Loading history...
21
 * @copyright   John Conde <[email protected]>
0 ignored issues
show
Coding Style introduced by
Tag value for @copyright tag indented incorrectly; expected 1 spaces but found 3
Loading history...
22
 * @license     http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0
0 ignored issues
show
Coding Style introduced by
Tag value for @license tag indented incorrectly; expected 3 spaces but found 5
Loading history...
23
 * @link        https://github.com/stymiee/authnetjson
0 ignored issues
show
Coding Style introduced by
Tag value for @link tag indented incorrectly; expected 6 spaces but found 8
Loading history...
24
 * @see         https://developer.authorize.net/api/reference/
0 ignored issues
show
Coding Style introduced by
Tag value for @see tag indented incorrectly; expected 7 spaces but found 9
Loading history...
25
 *
26
 * @property    object  $messages
0 ignored issues
show
Coding Style introduced by
Tag value for @property tag indented incorrectly; expected 1 spaces but found 4
Loading history...
27
 * @property    string  $directResponse
0 ignored issues
show
Coding Style introduced by
Tag value for @property tag indented incorrectly; expected 1 spaces but found 4
Loading history...
28
 * @property    string  $validationDirectResponse
0 ignored issues
show
Coding Style introduced by
Tag value for @property tag indented incorrectly; expected 1 spaces but found 4
Loading history...
29
 * @property    object  $transactionResponse
0 ignored issues
show
Coding Style introduced by
Tag value for @property tag indented incorrectly; expected 1 spaces but found 4
Loading history...
30
 *
31
 * @method null createTransactionRequest(array $array)                                 process a payment
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 104 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...
32
 * @method null sendCustomerTransactionReceiptRequest(array $array)                    get a list of unsettled transactions
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 123 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...
33
 * @method null ARBCancelSubscriptionRequest(array $array)                             cancel a subscription
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 108 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...
34
 * @method null ARBCreateSubscriptionRequest(array $array)                             create a subscription
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 108 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...
35
 * @method null ARBGetSubscriptionStatusRequest(array $array)                          get a subscription's status
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 114 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...
36
 * @method null ARBUpdateSubscriptionRequest(array $array)                             update a subscription
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 108 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...
37
 * @method null createCustomerPaymentProfileRequest(array $array)                      create a payment profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 111 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...
38
 * @method null createCustomerProfileRequest(array $array)                             create a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 112 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...
39
 * @method null createCustomerProfileTransactionRequest_authCapture(array $array)      process an Authorization and Capture transaction (Sale)
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 142 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...
40
 * @method null createCustomerProfileTransactionRequest_authOnly(array $array)         process an Authorization Only transaction
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 128 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...
41
 * @method null createCustomerProfileTransactionRequest_captureOnly(array $array)      process a Capture Only transaction
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 121 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...
42
 * @method null createCustomerProfileTransactionRequest_priorAuthCapture(array $array) process a Prior Authorization Capture transaction
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 136 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...
43
 * @method null createCustomerProfileTransactionRequest_refund(array $array)           process a Refund (credit)
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 112 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...
44
 * @method null createCustomerProfileTransactionRequest_void(array $array)             void a transaction
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 105 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...
45
 * @method null createCustomerShippingAddressRequest(array $array)                     create a shipping profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 112 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...
46
 * @method null deleteCustomerPaymentProfileRequest(array $array)                      delete a payment profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 111 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...
47
 * @method null deleteCustomerProfileRequest(array $array)                             delete a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 112 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...
48
 * @method null deleteCustomerShippingAddressRequest(array $array)                     delete a shipping profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 112 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...
49
 * @method null getCustomerPaymentProfileRequest(array $array)                         retrieve a payment profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 113 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...
50
 * @method null getCustomerProfileIdsRequest(array $array)                             retrieve a list of profile IDs
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 117 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...
51
 * @method null getCustomerProfileRequest(array $array)                                retrieve a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 114 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...
52
 * @method null getCustomerShippingAddressRequest(array $array)                        retrieve a shipping address
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 114 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...
53
 * @method null getHostedProfilePageRequest(array $array)                              retrieve a hosted payment page token
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 123 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...
54
 * @method null updateCustomerPaymentProfileRequest(array $array)                      update a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 112 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...
55
 * @method null updateCustomerProfileRequest(array $array)                             update a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 112 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...
56
 * @method null updateCustomerShippingAddressRequest(array $array)                     update a shipping address
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 112 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...
57
 * @method null updateSplitTenderGroupRequest(array $array)                            update a split tender transaction
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 120 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...
58
 * @method null validateCustomerPaymentProfileRequest(array $array)                    validate a payment profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 113 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...
59
 * @method null getBatchStatisticsRequest(array $array)                                get a summary of a settled batch
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...
60
 * @method null getSettledBatchListRequest(array $array)                               get a list of settled batches
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 116 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...
61
 * @method null getTransactionDetailsRequest(array $array)                             get the details of a transaction
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...
62
 * @method null getTransactionListRequest(array $array)                                get a list of transaction in a batch
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 123 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...
63
 * @method null getUnsettledTransactionListRequest(array $array)                       get a list of unsettled transactions
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 123 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...
64
 */
65
class AuthnetJsonResponse
66
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class AuthnetJsonResponse
Loading history...
67
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
68
     * @const Indicates the status code of an approved transaction
69
     */
70
    public const STATUS_APPROVED = 1;
71
72
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
73
     * @const Indicates the status code of an declined transaction
74
     */
75
    public const STATUS_DECLINED = 2;
76
77
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
78
     * @const Indicates the status code of an transaction which has encountered an error
79
     */
80
    public const STATUS_ERROR = 3;
81
82
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
83
     * @const Indicates the status code of a transaction held for review
84
     */
85
    public const STATUS_HELD = 4;
86
87
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
88
     * @const Indicates the status code of a transaction held for review
89
     */
90
    public const STATUS_PAYPAL_NEED_CONSENT = 5;
91
92
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
93
     * @var     object  SimpleXML object representing the API response
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
94
     */
95
    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...
96
97
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
98
     * @var     string  JSON string that is the response sent by Authorize.Net
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
99
     */
100
    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...
101
102
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
103
     * @var     object  TransactionResponse
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
104
     */
105
    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...
106
107
    /**
108
     * Creates the response object with the response json returned from the API call
109
     *
110
     * @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 3
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 3 found
Loading history...
111
     * @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...
Coding Style introduced by
Tag value for @throws tag indented incorrectly; expected 1 spaces but found 2
Loading history...
112
     */
113 3
    public function __construct(string $responseJson)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
114
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
115 3
        $this->responseJson = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $responseJson);
116 3
        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...
117 1
            throw new AuthnetInvalidJsonException('Invalid JSON returned by the API');
118
        }
119
120 2
        if ($this->directResponse || $this->validationDirectResponse) {
121 2
            $dr = $this->directResponse ?: $this->validationDirectResponse;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 20 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...
Coding Style introduced by
The value of a comparison must not be assigned to a variable
Loading history...
Coding Style introduced by
Inline IF statements are not allowed
Loading history...
Coding Style introduced by
Inline shorthand IF statement requires brackets around comparison
Loading history...
122 2
            $this->transactionInfo = new TransactionResponse($dr);
123
        }
124 2
    }
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...
125
126
    /**
127
     * Outputs the response JSON in a human readable format
128
     *
129
     * @return  string  HTML table containing debugging information
0 ignored issues
show
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
130
     */
131 1
    public function __toString()
132
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
133 1
        $output  = '<table id="authnet-response">'."\n";
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "."; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "."; 0 found
Loading history...
134 1
        $output .= '<caption>Authorize.Net Response</caption>'."\n";
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "."; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "."; 0 found
Loading history...
135 1
        $output .= '<tr><th colspan="2"><b>Response JSON</b></th></tr>'."\n";
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "."; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "."; 0 found
Loading history...
136 1
        $output .= '<tr><td colspan="2"><pre>'."\n";
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "."; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "."; 0 found
Loading history...
137 1
        $output .= $this->responseJson."\n";
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "."; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "."; 0 found
Loading history...
138 1
        $output .= '</pre></td></tr>'."\n";
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space before "."; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "."; 0 found
Loading history...
139 1
        $output .= '</table>';
140
141 1
        return $output;
142
    }
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...
143
144
    /**
145
     * Gets a response variable from the API response
146
     *
147
     * @param   string  $var    unused
0 ignored issues
show
introduced by
Parameter comment must start with a capital letter
Loading history...
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 3
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 4 found
Loading history...
148
     * @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...
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
149
     */
150 1
    public function __get(string $var)
151
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
152 1
        return $this->response->{$var} ?? 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...
153
    }
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...
154
155
    /**
156
     * Checks if the API call is not in an error state
157
     *
158
     * @return  bool    Whether the transaction was in an successful state
0 ignored issues
show
Coding Style introduced by
Expected "boolean" but found "bool" for function return type
Loading history...
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
159
     */
160 2
    public function isSuccessful() : bool
161
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
162 2
        return strtolower($this->messages->resultCode) === 'ok';
163
    }
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...
164
165
    /**
166
     * Checks if the API is reporting an error with the API call
167
     *
168
     * @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...
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
169
     */
170 2
    public function isError() : bool
171
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
172 2
        return strtolower($this->messages->resultCode) === 'error';
173
    }
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...
174
175
    /**
176
     * Checks if a transaction was approved
177
     *
178
     * @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...
179
     */
180 1
    public function isApproved() : bool
181
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
182 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...
183
    }
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...
184
185
    /**
186
     * Checks if a transaction was completed using a prepaid card
187
     *
188
     * @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...
189
     */
190 1
    public function isPrePaidCard() : bool
191
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
192 1
        return isset($this->transactionResponse->prePaidCard);
193
    }
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...
194
195
    /**
196
     * Checks if a transaction was declined
197
     *
198
     * @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...
199
     */
200 1
    public function isDeclined() : bool
201
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
202 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...
203
    }
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...
204
205
    /**
206
     * Check to see if the ResponseCode matches the expected value
207
     *
208
     * @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
Expected 1 spaces after parameter type; 5 found
Loading history...
209
     * @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...
210
     */
211 2
    protected function checkTransactionStatus(int $status) : bool
0 ignored issues
show
Coding Style introduced by
function checkTransactionStatus() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
212
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
213 2
        if ($this->transactionInfo instanceof TransactionResponse) {
214 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
A cast statement should not be followed as per the coding-style.
Loading history...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 107 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...
215
        } else {
216 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
A cast statement should not be followed as per the coding-style.
Loading history...
217
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
218 2
        return $match;
219
    }
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 checkTransactionStatus()
Loading history...
220
221
    /**
222
     * Gets the transaction response field for AIM and CIM transactions.
223
     *
224
     * @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 3
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 2 found
Loading history...
225
     * @return  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...
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
226
     * @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...
Coding Style introduced by
Tag value for @throws tag indented incorrectly; expected 1 spaces but found 2
Loading history...
227
     */
228 2
    public function getTransactionResponseField($field) : string
229
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
230 2
        if ($this->transactionInfo instanceof TransactionResponse) {
231 1
            return $this->transactionInfo->getTransactionResponseField($field);
232
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
233 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...
234
    }
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...
235
236
    /**
237
     * Gets the transaction response from Authorize.Net in JSON format for logging purposes
238
     *
239
     * @return  string transaction response from Authorize.Net in JSON format
0 ignored issues
show
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
240
     */
241 1
    public function getRawResponse() : string
242
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
243 1
        return $this->responseJson;
244
    }
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...
245
246
    /**
247
     * An alias of self::getErrorText()
248
     *
249
     * @return  string Error response from Authorize.Net
0 ignored issues
show
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
250
     */
251 1
    public function getErrorMessage() : string
252
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
253 1
        return $this->getErrorText();
254
    }
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...
255
256
    /**
257
     * If an error has occurred, returns the error message
258
     *
259
     * @return  string Error response from Authorize.Net
0 ignored issues
show
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
260
     */
261 2
    public function getErrorText() : string
262
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
263 2
        return $this->getError('text');
264
    }
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 getErrorText()
Loading history...
265
266
    /**
267
     * If an error has occurred, returns the error message
268
     *
269
     * @return  string Error response from Authorize.Net
0 ignored issues
show
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
270
     */
271 2
    public function getErrorCode() : 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
        return $this->getError('code');
274
    }
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 getErrorCode()
Loading history...
275
276
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
277
     * @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
Expected 1 spaces after parameter type; 3 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 5 found
Loading history...
278
     * @return string
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
279
     */
280 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...
281
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
282 2
        $msg = '';
283 2
        if ($this->isError()) {
284 2
            $prop = sprintf('error%s', ucfirst($type));
285 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...
286 2
            if (@$this->transactionResponse->errors[0]->{$prop}) {
0 ignored issues
show
Coding Style introduced by
Silencing errors is discouraged; found: @$this->transactionResponse...
Loading history...
287 1
                $msg = $this->transactionResponse->errors[0]->{$prop};
288
            }
289
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
290 2
        return $msg;
291
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 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 getError()
Loading history...
292
}
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...
293