Passed
Push — master ( ed3501...c69f21 )
by John
02:43
created

AuthnetJsonRequest::__toString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 14
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 18
ccs 14
cts 14
cp 1
rs 9.6666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
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 "AuthnetJsonRequest.php" doesn't match the expected filename "authnetjsonrequest.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
use \Curl\Curl;
17
18
/**
19
 * Creates a request to the Authorize.Net JSON endpoints.
20
 *
21
 * @package   AuthnetJSON
22
 * @author    John Conde <[email protected]>
23
 * @copyright John Conde <[email protected]>
24
 * @license   http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0
25
 * @link      https://github.com/stymiee/authnetjson
26
 * @see       https://developer.authorize.net/api/reference/
27
 *
28
 * @method AuthnetJsonResponse createTransactionRequest(array $array)
29
 * @method AuthnetJsonResponse sendCustomerTransactionReceiptRequest(array $array)
30
 * @method AuthnetJsonResponse ARBCancelSubscriptionRequest(array $array)
31
 * @method AuthnetJsonResponse ARBCreateSubscriptionRequest(array $array)
32
 * @method AuthnetJsonResponse ARBGetSubscriptionStatusRequest(array $array)
33
 * @method AuthnetJsonResponse ARBUpdateSubscriptionRequest(array $array)
34
 * @method AuthnetJsonResponse getAUJobDetailsRequest(array $array)
35
 * @method AuthnetJsonResponse getAUJobSummaryRequest(array $array)
36
 * @method AuthnetJsonResponse createCustomerPaymentProfileRequest(array $array)
37
 * @method AuthnetJsonResponse createCustomerProfileRequest(array $array)
38
 * @method AuthnetJsonResponse createCustomerProfileTransactionRequest_authCapture(array $array)
39
 * @method AuthnetJsonResponse createCustomerProfileTransactionRequest_authOnly(array $array)
40
 * @method AuthnetJsonResponse createCustomerProfileTransactionRequest_captureOnly(array $array)
41
 * @method AuthnetJsonResponse createCustomerProfileTransactionRequest_priorAuthCapture(array $array)
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 101 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 AuthnetJsonResponse createCustomerProfileTransactionRequest_refund(array $array)
43
 * @method AuthnetJsonResponse createCustomerProfileTransactionRequest_void(array $array)
44
 * @method AuthnetJsonResponse createCustomerShippingAddressRequest(array $array)
45
 * @method AuthnetJsonResponse deleteCustomerPaymentProfileRequest(array $array)
46
 * @method AuthnetJsonResponse deleteCustomerProfileRequest(array $array)
47
 * @method AuthnetJsonResponse deleteCustomerShippingAddressRequest(array $array)
48
 * @method AuthnetJsonResponse getCustomerPaymentProfileRequest(array $array)
49
 * @method AuthnetJsonResponse getCustomerProfileIdsRequest(array $array)
50
 * @method AuthnetJsonResponse getCustomerProfileRequest(array $array)
51
 * @method AuthnetJsonResponse getCustomerShippingAddressRequest(array $array)
52
 * @method AuthnetJsonResponse getHostedPaymentPageRequest(array $array)
53
 * @method AuthnetJsonResponse getHostedProfilePageRequest(array $array)
54
 * @method AuthnetJsonResponse getMerchantDetailsRequest(array $array)
55
 * @method AuthnetJsonResponse getUnsettledTransactionListRequest(array $array)
56
 * @method AuthnetJsonResponse updateCustomerPaymentProfileRequest(array $array)
57
 * @method AuthnetJsonResponse updateCustomerProfileRequest(array $array)
58
 * @method AuthnetJsonResponse updateCustomerShippingAddressRequest(array $array)
59
 * @method AuthnetJsonResponse updateHeldTransactionRequest(array $array)
60
 * @method AuthnetJsonResponse updateSplitTenderGroupRequest(array $array)
61
 * @method AuthnetJsonResponse validateCustomerPaymentProfileRequest(array $array)
62
 * @method AuthnetJsonResponse getBatchStatisticsRequest(array $array)
63
 * @method AuthnetJsonResponse getSettledBatchListRequest(array $array)
64
 * @method AuthnetJsonResponse getTransactionDetailsRequest(array $array)
65
 * @method AuthnetJsonResponse getTransactionListRequest(array $array)
66
 */
67
class AuthnetJsonRequest
68
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class AuthnetJsonRequest
Loading history...
69
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
70
     * @var int     Maximum number of retires making HTTP request before failure
71
     */
72
    private const MAX_RETRIES = 3;
73
74
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
75
     * @var string  Authorize.Net API login ID
76
     */
77
    private $login;
0 ignored issues
show
Coding Style introduced by
Private member variable "login" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "login" must be prefixed with an underscore
Loading history...
78
79
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
80
     * @var string  Authorize.Net API Transaction Key
81
     */
82
    private $transactionKey;
0 ignored issues
show
Coding Style introduced by
Private member variable "transactionKey" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "transactionKey" must be prefixed with an underscore
Loading history...
83
84
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
85
     * @var string  URL endpoint for processing a transaction
86
     */
87
    private $url;
0 ignored issues
show
Coding Style introduced by
Private member variable "url" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "url" must be prefixed with an underscore
Loading history...
88
89
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
90
     * @var string  JSON formatted API request
91
     */
92
    private $requestJson;
0 ignored issues
show
Coding Style introduced by
Private member variable "requestJson" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "requestJson" must be prefixed with an underscore
Loading history...
93
94
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
95
     * @var object  Wrapper object representing an endpoint
96
     */
97
    private $processor;
0 ignored issues
show
Coding Style introduced by
Private member variable "processor" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "processor" must be prefixed with an underscore
Loading history...
98
99
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
100
     * @var int Counts number of retries to make API call. Up to self::MAX_RETRIES
101
     */
102
    private $retries;
0 ignored issues
show
Coding Style introduced by
Private member variable "retries" must contain a leading underscore
Loading history...
Coding Style introduced by
Private member variable "retries" must be prefixed with an underscore
Loading history...
103
104
    /**
105
     * Creates the request object by setting the Authorize.Net credentials and URL of the endpoint to be used
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...
106
     * for the API call.
107
     *
108
     * @param string $login          Authorize.Net API login ID
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
109
     * @param string $transactionKey Authorize.Net API Transaction Key
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
110
     * @param string $api_url        URL endpoint for processing a transaction
0 ignored issues
show
introduced by
Parameter comment must end with a full stop
Loading history...
111
     */
112 1
    public function __construct(string $login, string $transactionKey, string $api_url)
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Variable "api_url" is not in valid camel caps format
Loading history...
Coding Style introduced by
$api_url does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
113
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
114 1
        $this->login          = $login;
115 1
        $this->transactionKey = $transactionKey;
116 1
        $this->url            = $api_url;
0 ignored issues
show
Coding Style introduced by
Variable "api_url" is not in valid camel caps format
Loading history...
Coding Style introduced by
$api_url does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
117 1
    }
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...
118
119
    /**
120
     * Outputs the account credentials, endpoint URL, and request JSON in a human readable format
121
     *
122
     * @return string  HTML table containing debugging information
123
     */
124 1
    public function __toString()
125
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
126 1
        $output  = '<table id="authnet-request">'."\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...
127 1
        $output .= '<caption>Authorize.Net Request</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...
128 1
        $output .= '<tr><th colspan="2"><b>Class Parameters</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...
129 1
        $output .= '<tr><td><b>API Login ID</b></td><td>'.$this->login.'</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...
130 1
        $output .= '<tr><td><b>Transaction Key</b></td><td>'.$this->transactionKey.'</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...
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 101 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...
131 1
        $output .= '<tr><td><b>Authnet Server URL</b></td><td>'.$this->url.'</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...
132 1
        $output .= '<tr><th colspan="2"><b>Request 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...
133 1
        if (!empty($this->requestJson)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
134 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...
135 1
            $output .= $this->requestJson."\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 .= '</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...
137
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
138 1
        $output .= '</table>';
139
140 1
        return $output;
141
    }
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...
142
143
    /**
144
     * The __set() method should never be used as all values to be made in the API call must be passed as an array
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...
145
     *
146
     * @param  string $name  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...
147
     * @param  mixed  $value 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...
148
     * @throws AuthnetCannotSetParamsException
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...
149
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
150 2
    public function __set($name, $value)
0 ignored issues
show
Coding Style introduced by
The method parameter $name is never used
Loading history...
Coding Style introduced by
The method parameter $value is never used
Loading history...
Coding Style introduced by
Type hint "string" missing for $name
Loading history...
151
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
152 2
        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...
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 __set()
Loading history...
154
155
    /**
156
     * Magic method that dynamically creates our API call based on the name of the method in the client code and
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...
157
     * the array passed as its parameter.
158
     *
159
     * @param  string $api_call name of the API call to be made
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...
160
     * @param  array  $args     the array to be passed to the API
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...
161
     * @return AuthnetJsonResponse
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
162
     * @throws AuthnetCurlException
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...
163
     * @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...
164
     */
165 1
    public function __call($api_call, array $args)
0 ignored issues
show
Coding Style introduced by
Type hint "string" missing for $api_call
Loading history...
Coding Style introduced by
Variable "api_call" is not in valid camel caps format
Loading history...
Coding Style introduced by
$api_call does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
166
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
167
        $authentication = [
168
            'merchantAuthentication' => [
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 27 spaces, but found 12.
Loading history...
Coding Style introduced by
Each line in an array declaration must end in a comma
Loading history...
169 1
                'name'           => $this->login,
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 41 spaces, but found 16.
Loading history...
170 1
                'transactionKey' => $this->transactionKey,
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 41 spaces, but found 16.
Loading history...
171
            ]
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 40 space(s), but found 12.
Loading history...
172
        ];
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 26 space(s), but found 8.
Loading history...
173 1
        $call = [];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 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...
174 1
        if (count($args)) {
175 1
            $call = $args[0];
176
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
177
        $parameters = [
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 8 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...
178 1
            $api_call => $authentication + $call
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 23 spaces, but found 12.
Loading history...
Coding Style introduced by
Variable "api_call" is not in valid camel caps format
Loading history...
Coding Style introduced by
Each line in an array declaration must end in a comma
Loading history...
Coding Style introduced by
Operation must be bracketed
Loading history...
Coding Style introduced by
$api_call does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
179
        ];
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 22 space(s), but found 8.
Loading history...
180 1
        $this->requestJson = json_encode($parameters);
181
182 1
        $response = $this->process();
183 1
        return new AuthnetJsonResponse($response);
184
    }
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 __call()
Loading history...
185
186
    /**
187
     * Makes POST request with retry logic.
188
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
189 2
    private function makeRequest() : void
0 ignored issues
show
Coding Style introduced by
Private method name "AuthnetJsonRequest::makeRequest" must be prefixed with an underscore
Loading history...
190
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
191 2
        $this->retries = 0;
192 2
        while ($this->retries < self::MAX_RETRIES) {
193 2
            $this->processor->post($this->url, $this->requestJson);
194 2
            if (!$this->processor->error) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
195 1
                break;
196
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
197 1
            $this->retries++;
198
        }
199 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 makeRequest()
Loading history...
200
201
    /**
202
     * Tells the handler to make the API call to Authorize.Net.
203
     *
204
     * @return string  JSON string containing API response
205
     * @throws AuthnetCurlException
0 ignored issues
show
introduced by
Comment missing for @throws tag in function comment
Loading history...
206
     */
207 72
    private function process() : string
0 ignored issues
show
Coding Style introduced by
Private method name "AuthnetJsonRequest::process" must be prefixed with an underscore
Loading history...
208
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
209 72
        $this->makeRequest();
210 72
        if (!$this->processor->error && isset($this->processor->response)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
211 70
            return $this->processor->response;
212
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
213 2
        $error_message = null;
0 ignored issues
show
Coding Style introduced by
Variable "error_message" is not in valid camel caps format
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...
Coding Style introduced by
$error_message does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
214 2
        $error_code    = null;
0 ignored issues
show
Coding Style introduced by
Variable "error_code" is not in valid camel caps format
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...
Coding Style introduced by
$error_code does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
215 2
        if ($this->processor->error_code || $this->processor->error_message) {
216 1
            $error_message = $this->processor->error_message;
0 ignored issues
show
Coding Style introduced by
Variable "error_message" is not in valid camel caps format
Loading history...
Coding Style introduced by
$error_message does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
217 1
            $error_code    = $this->processor->error_code;
0 ignored issues
show
Coding Style introduced by
Variable "error_code" is not in valid camel caps format
Loading history...
Coding Style introduced by
$error_code does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
218
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
219 2
        throw new AuthnetCurlException(sprintf('Connection error: %s (%s)', $error_message, $error_code));
0 ignored issues
show
Coding Style introduced by
Variable "error_message" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "error_code" is not in valid camel caps format
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...
Coding Style introduced by
$error_message does not seem to conform to the naming convention (^[a-z][a-zA-Z0-9]*$).

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...
220
    }
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 process()
Loading history...
221
222
    /**
223
     * Sets the handler to be used to handle our API call. Mainly used for unit testing as Curl is used by default.
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...
224
     *
225
     * @param Curl $processor
0 ignored issues
show
Documentation introduced by
Missing parameter comment
Loading history...
226
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
227 1
    public function setProcessHandler($processor) : void
0 ignored issues
show
introduced by
Type hint "Curl" missing for $processor
Loading history...
228
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
229 1
        $this->processor = $processor;
230 1
    }
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 setProcessHandler()
Loading history...
231
232
    /**
233
     * Gets the request sent to Authorize.Net in JSON format for logging purposes.
234
     *
235
     * @return string transaction request sent to Authorize.Net in JSON format
236
     */
237 1
    public function getRawRequest() : string
238
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
239 1
        return $this->requestJson;
240
    }
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 getRawRequest()
Loading history...
241
}
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...
242