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

AuthnetJsonRequest::makeRequest()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 8
cts 8
cp 1
rs 9.9
c 0
b 0
f 0
cc 3
nc 3
nop 0
crap 3
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
0 ignored issues
show
Coding Style introduced by
Tag value for @package tag indented incorrectly; expected 3 spaces but found 5
Loading history...
22
 * @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...
23
 * @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...
24
 * @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...
25
 * @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...
26
 * @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...
27
 *
28
 * @method AuthnetJsonResponse createTransactionRequest(array $array)                                 process a payment
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...
29
 * @method AuthnetJsonResponse 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 138 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...
30
 * @method AuthnetJsonResponse ARBCancelSubscriptionRequest(array $array)                             cancel a subscription
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...
31
 * @method AuthnetJsonResponse ARBCreateSubscriptionRequest(array $array)                             create a subscription
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...
32
 * @method AuthnetJsonResponse 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 129 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 AuthnetJsonResponse ARBUpdateSubscriptionRequest(array $array)                             update a subscription
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...
34
 * @method AuthnetJsonResponse createCustomerPaymentProfileRequest(array $array)                      create a payment profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 126 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 AuthnetJsonResponse createCustomerProfileRequest(array $array)                             create a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 127 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 AuthnetJsonResponse 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 157 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 AuthnetJsonResponse 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 143 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 AuthnetJsonResponse 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 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...
39
 * @method AuthnetJsonResponse 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 151 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 AuthnetJsonResponse 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 127 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 AuthnetJsonResponse createCustomerProfileTransactionRequest_void(array $array)             void a 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...
42
 * @method AuthnetJsonResponse createCustomerShippingAddressRequest(array $array)                     create a shipping profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 127 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 AuthnetJsonResponse deleteCustomerPaymentProfileRequest(array $array)                      delete a payment profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 126 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 AuthnetJsonResponse deleteCustomerProfileRequest(array $array)                             delete a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 127 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 AuthnetJsonResponse deleteCustomerShippingAddressRequest(array $array)                     delete a shipping profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 127 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 AuthnetJsonResponse getCustomerPaymentProfileRequest(array $array)                         retrieve a payment profile
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...
47
 * @method AuthnetJsonResponse 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 132 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 AuthnetJsonResponse getCustomerProfileRequest(array $array)                                retrieve a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 129 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 AuthnetJsonResponse getCustomerShippingAddressRequest(array $array)                        retrieve a shipping address
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 129 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 AuthnetJsonResponse 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 138 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 AuthnetJsonResponse updateCustomerPaymentProfileRequest(array $array)                      update a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 127 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 AuthnetJsonResponse updateCustomerProfileRequest(array $array)                             update a customer profile
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 127 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 AuthnetJsonResponse updateCustomerShippingAddressRequest(array $array)                     update a shipping address
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 100 characters; contains 127 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 AuthnetJsonResponse 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 135 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 AuthnetJsonResponse validateCustomerPaymentProfileRequest(array $array)                    validate a payment profile
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...
56
 * @method AuthnetJsonResponse 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 134 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 AuthnetJsonResponse 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 131 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 AuthnetJsonResponse 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 134 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 AuthnetJsonResponse 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 138 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 AuthnetJsonResponse 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 138 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
 */
62
class AuthnetJsonRequest
63
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class AuthnetJsonRequest
Loading history...
64
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
65
     * @var     int     Maximum number of retires making HTTP request before failure
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
66
     */
67
    private const MAX_RETRIES = 3;
68
69
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
70
     * @var     string  Authorize.Net API login ID
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
71
     */
72
    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...
73
74
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
75
     * @var     string  Authorize.Net API Transaction Key
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
76
     */
77
    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...
78
79
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
80
     * @var     string  URL endpoint for processing a transaction
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
81
     */
82
    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...
83
84
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
85
     * @var     string  JSON formatted API request
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
86
     */
87
    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...
88
89
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
90
     * @var     object  Wrapper object representing an endpoint
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
91
     */
92
    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...
93
94
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
95
     * @var     int  Number of attempts to make an HTTP request
0 ignored issues
show
Coding Style introduced by
Tag value for @var tag indented incorrectly; expected 1 spaces but found 5
Loading history...
96
     */
97
    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...
98
99
    /**
100
     * 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...
101
     * for the API call.
102
     *
103
     * @param   string  $login              Authorize.Net API login ID
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 10 spaces after parameter name; 14 found
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 1 spaces but found 3
Loading history...
104
     * @param   string  $transactionKey     Authorize.Net API Transaction Key
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 5 found
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 1 spaces but found 3
Loading history...
105
     * @param   string  $api_url            URL endpoint for processing a transaction
0 ignored issues
show
Coding Style introduced by
Expected 8 spaces after parameter name; 12 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
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 1 spaces but found 3
Loading history...
106
     */
107 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...
108
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
109 1
        $this->login          = $login;
110 1
        $this->transactionKey = $transactionKey;
111 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...
112 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...
113
114
    /**
115
     * Outputs the account credentials, endpoint URL, and request JSON in a human readable format
116
     *
117
     * @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...
118
     */
119 1
    public function __toString()
120
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
121 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...
122 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...
123 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...
124 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...
125 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...
126 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...
127 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...
128 1
        if (!empty($this->requestJson)) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
129 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...
130 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...
131 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...
132
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
133 1
        $output .= '</table>';
134
135 1
        return $output;
136
    }
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...
137
138
    /**
139
     * 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...
140
     *
141
     * @param   string  $name       unused
0 ignored issues
show
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Expected 2 spaces after parameter name; 7 found
Loading history...
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...
142
     * @param   mixed   $value      unused
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 3 found
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter name; 6 found
Loading history...
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...
143
     * @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...
Coding Style introduced by
Tag value for @throws tag indented incorrectly; expected 1 spaces but found 2
Loading history...
144
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
145 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...
146
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
147 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...
148
    }
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...
149
150
    /**
151
     * 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...
152
     * the array passed as its parameter.
153
     *
154
     * @param   string  $api_call   name of the API call to be made
0 ignored issues
show
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...
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...
155
     * @param   array   $args       the array to be passed to the API
0 ignored issues
show
Coding Style introduced by
Expected 2 spaces after parameter type; 3 found
Loading history...
Coding Style introduced by
Expected 5 spaces after parameter name; 7 found
Loading history...
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...
156
     * @return  AuthnetJsonResponse
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...
157
     * @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...
Coding Style introduced by
Tag value for @throws tag indented incorrectly; expected 1 spaces but found 2
Loading history...
158
     * @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...
159
     */
160 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
PHP parameter type declarations must be lowercase; expected "array" but found "Array"
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...
161
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
162
        $authentication = [
163
            '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...
164 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...
165 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...
166
            ]
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...
167
        ];
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...
168 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...
169 1
        if (count($args)) {
170 1
            $call = $args[0];
171
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
172
        $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...
173 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...
174
        ];
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...
175 1
        $this->requestJson = json_encode($parameters);
176
177 1
        $response = $this->process();
178 1
        return new AuthnetJsonResponse($response);
179
    }
0 ignored issues
show
Coding Style introduced by
Expected //end __call()
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...
180
181
    /**
182
     * Makes POST request with retry logic.
183
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
184 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...
185
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
186 2
        $this->retries = 0;
187 2
        while ($this->retries < self::MAX_RETRIES) {
188 2
            $this->processor->post($this->url, $this->requestJson);
189 2
            if (!$this->processor->error) {
0 ignored issues
show
Coding Style introduced by
Expected 1 space(s) after NOT operator; 0 found
Loading history...
190 1
                break;
191
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
192 1
            $this->retries++;
193
        }
194 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...
195
196
    /**
197
     * Tells the handler to make the API call to Authorize.Net.
198
     *
199
     * @return  string  JSON string containing API response
0 ignored issues
show
Coding Style introduced by
Tag value for @return tag indented incorrectly; expected 1 spaces but found 2
Loading history...
200
     * @throws  AuthnetCurlException
0 ignored issues
show
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...
201
     */
202 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...
203
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
204 72
        $this->makeRequest();
205 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...
206 70
            return $this->processor->response;
207
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
208 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...
209 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...
210 2
        if ($this->processor->error_code || $this->processor->error_message) {
211 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...
212 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...
213
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
214 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...
215
    }
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...
216
217
    /**
218
     * 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...
219
     *
220
     * @param   Curl  $processor
0 ignored issues
show
Documentation introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 1 spaces after parameter type; 2 found
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 1 spaces but found 3
Loading history...
221
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
222 1
    public function setProcessHandler($processor) : void
0 ignored issues
show
introduced by
Type hint "Curl" missing for $processor
Loading history...
223
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
224 1
        $this->processor = $processor;
225 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...
226
227
    /**
228
     * Gets the request sent to Authorize.Net in JSON format for logging purposes.
229
     *
230
     * @return  string transaction request sent to 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...
231
     */
232 1
    public function getRawRequest() : string
233
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
234 1
        return $this->requestJson;
235
    }
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...
236
}
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...
237