Passed
Push — master ( 85716f...d04990 )
by John
05:03 queued 10s
created

AuthnetApiFactory::getJsonApiHandler()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 21
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 14
nc 2
nop 3
dl 0
loc 21
ccs 15
cts 15
cp 1
crap 3
rs 9.7998
c 0
b 0
f 0
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 "AuthnetApiFactory.php" doesn't match the expected filename "authnetapifactory.php"
Loading history...
2
3
declare(strict_types=1);
4
5
/**
0 ignored issues
show
Coding Style introduced by
Block comments must be started with /*
Loading history...
6
 * This file is part of the AuthnetJSON package.
7
 *
8
 * (c) John Conde <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Authnetjson;
15
16
use Curl\Curl;
17
use Exception;
18
19
/**
20
 * Factory to instantiate an instance of an AuthnetJson object with the proper endpoint
21
 * URL and Processor Class.
22
 *
23
 * @author    John Conde <[email protected]>
24
 * @copyright John Conde <[email protected]>
25
 * @license   http://www.apache.org/licenses/LICENSE-2.0.html Apache License, Version 2.0
26
 *
27
 * @link https://github.com/stymiee/authnetjson
28
 */
29
class AuthnetApiFactory
30
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class AuthnetApiFactory
Loading history...
31
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
32
     * @const Indicates use of Authorize.Net's production server
33
     */
34
    public const USE_PRODUCTION_SERVER = 0;
35
36
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
37
     * @const Indicates use of the development server
38
     */
39
    public const USE_DEVELOPMENT_SERVER = 1;
40
41
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
42
     * @const Indicates use of the CDN endpoint
43
     */
44
    public const USE_CDN_SERVER = 2;
45
46
    /**
47
     * Validates the Authorize.Net credentials and returns a Request object to be used to make an API call.
0 ignored issues
show
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...
48
     *
49
     * @param string $login Authorize.Net API Login ID
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 11 spaces after parameter name; 1 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 2 spaces but found 1
Loading history...
50
     * @param string $transaction_key Authorize.Net API Transaction Key
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 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 2 spaces but found 1
Loading history...
51
     * @param int|null $endpoint ID of which endpoint to use (optional)
0 ignored issues
show
Coding Style introduced by
Expected "integer|null" but found "int|null" for parameter type
Loading history...
Coding Style introduced by
Expected 8 spaces after parameter name; 1 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 2 spaces but found 1
Loading history...
52
     * @return AuthnetJsonRequest
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
53
     * @throws AuthnetInvalidCredentialsException
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...
54
     * @throws AuthnetInvalidServerException
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...
55
     */
56 6
    public static function getJsonApiHandler(string $login, string $transaction_key, ?int $endpoint = null): object
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 1 found
Loading history...
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$endpoint" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$endpoint"; expected 0 but found 1
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
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...
57
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
58 6
        $login           = trim($login);
59 6
        $transaction_key = trim($transaction_key);
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
60 6
        $endpoint        = $endpoint ?? self::USE_CDN_SERVER;
0 ignored issues
show
Coding Style introduced by
Operation must be bracketed
Loading history...
61 6
        $api_url         = static::getWebServiceURL($endpoint);
0 ignored issues
show
Coding Style introduced by
Variable "api_url" is not in valid camel caps format
Loading history...
62
63 5
        if (empty($login) || empty($transaction_key)) {
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
64 2
            throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.');
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...
65
        }
66
67 3
        $curl = new Curl();
68 3
        $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
69 3
        $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
0 ignored issues
show
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...
70 3
        $curl->setOpt(CURLOPT_HEADER, false);
0 ignored issues
show
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...
71 3
        $curl->setHeader('Content-Type', 'text/json');
72
73 3
        $object = new AuthnetJsonRequest($login, $transaction_key, $api_url);
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "api_url" is not in valid camel caps format
Loading history...
74 3
        $object->setProcessHandler($curl);
75
76 3
        return $object;
77
    }
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 getJsonApiHandler()
Loading history...
78
79
    /**
80
     * Gets the API endpoint to be used for a JSON API call.
81
     *
82
     * @param  int $server ID of which server to use
0 ignored issues
show
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
83
     * @return string                  The URL endpoint the request is to be sent to
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
84
     * @throws AuthnetInvalidServerException
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...
85
     */
86 5
    protected static function getWebServiceURL(int $server): string
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
87
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
88
        $urls = [
89 5
            static::USE_PRODUCTION_SERVER  => 'https://api.authorize.net/xml/v1/request.api',
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 17 spaces, but found 12.
Loading history...
90 5
            static::USE_DEVELOPMENT_SERVER => 'https://apitest.authorize.net/xml/v1/request.api',
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 17 spaces, but found 12.
Loading history...
91 5
            static::USE_CDN_SERVER         => 'https://api2.authorize.net/xml/v1/request.api',
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 17 spaces, but found 12.
Loading history...
92
        ];
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 16 space(s), but found 8.
Loading history...
93 5
        if (array_key_exists($server, $urls)) {
94 4
            return $urls[$server];
95
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
96 1
        throw new AuthnetInvalidServerException('You did not provide a valid server.');
97
    }
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 getWebServiceURL()
Loading history...
98
99
    /**
100
     * Validates the Authorize.Net credentials and returns a SIM object to be used to make a SIM API call.
0 ignored issues
show
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...
101
     *
102
     * @param string $login Authorize.Net API Login ID
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 11 spaces after parameter name; 1 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 2 spaces but found 1
Loading history...
103
     * @param string $transaction_key Authorize.Net API Transaction Key
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 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 2 spaces but found 1
Loading history...
104
     * @param int|null $server ID of which server to use (optional)
0 ignored issues
show
Coding Style introduced by
Expected "integer|null" but found "int|null" for parameter type
Loading history...
Coding Style introduced by
Expected 10 spaces after parameter name; 1 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 2 spaces but found 1
Loading history...
105
     * @return AuthnetSim
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
106
     * @throws AuthnetInvalidCredentialsException
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...
107
     * @throws AuthnetInvalidServerException
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...
108
     * @throws Exception
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...
109
     */
110 2
    public static function getSimHandler(string $login, string $transaction_key, ?int $server = null): object
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$server" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$server"; expected 0 but found 1
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
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...
111
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
112 2
        $login           = trim($login);
113 2
        $transaction_key = trim($transaction_key);
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
114 2
        $server          = $server ?? self::USE_PRODUCTION_SERVER;
0 ignored issues
show
Coding Style introduced by
Operation must be bracketed
Loading history...
115 2
        $api_url         = static::getSimURL($server);
0 ignored issues
show
Coding Style introduced by
Variable "api_url" is not in valid camel caps format
Loading history...
116
117 2
        if (empty($login) || empty($transaction_key)) {
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
118 1
            throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.');
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...
119
        }
120
121 1
        return new AuthnetSim($login, $transaction_key, $api_url);
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
Coding Style introduced by
Variable "api_url" is not in valid camel caps format
Loading history...
122
    }
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 getSimHandler()
Loading history...
123
124
    /**
125
     * Gets the API endpoint to be used for a SIM API call.
126
     *
127
     * @param  int $server ID of which server to use
0 ignored issues
show
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
128
     * @return string                  The URL endpoint the request is to be sent to
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
129
     * @throws AuthnetInvalidServerException
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...
130
     */
131 3
    protected static function getSimURL(int $server): string
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
132
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
133
        $urls = [
134 3
            static::USE_PRODUCTION_SERVER  => 'https://secure2.authorize.net/gateway/transact.dll',
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 17 spaces, but found 12.
Loading history...
135 3
            static::USE_DEVELOPMENT_SERVER => 'https://test.authorize.net/gateway/transact.dll',
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 17 spaces, but found 12.
Loading history...
136
        ];
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 16 space(s), but found 8.
Loading history...
137 3
        if (array_key_exists($server, $urls)) {
138 2
            return $urls[$server];
139
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
140 1
        throw new AuthnetInvalidServerException('You did not provide a valid server.');
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 getSimURL()
Loading history...
142
143
    /**
144
     * Validates the Authorize.Net credentials and returns a Webhooks Request object to be used to make an Webhook call.
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...
145
     *
146
     * @param string $login Authorize.Net API Login ID
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Expected 11 spaces after parameter name; 1 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 2 spaces but found 1
Loading history...
147
     * @param string $transaction_key Authorize.Net API Transaction Key
0 ignored issues
show
Coding Style introduced by
Expected 3 spaces after parameter type; 1 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 2 spaces but found 1
Loading history...
148
     * @param int|null $server ID of which server to use (optional)
0 ignored issues
show
Coding Style introduced by
Expected "integer|null" but found "int|null" for parameter type
Loading history...
Coding Style introduced by
Expected 10 spaces after parameter name; 1 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 2 spaces but found 1
Loading history...
149
     * @return AuthnetWebhooksRequest
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
150
     * @throws AuthnetInvalidCredentialsException
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...
151
     * @throws AuthnetInvalidServerException
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...
152
     */
153 5
    public static function getWebhooksHandler(string $login, string $transaction_key, ?int $server = null): object
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$server" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$server"; expected 0 but found 1
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
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...
154
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
155 5
        $login           = trim($login);
156 5
        $transaction_key = trim($transaction_key);
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
157 5
        $server          = $server ?? self::USE_PRODUCTION_SERVER;
0 ignored issues
show
Coding Style introduced by
Operation must be bracketed
Loading history...
158 5
        $api_url         = static::getWebhooksURL($server);
0 ignored issues
show
Coding Style introduced by
Variable "api_url" is not in valid camel caps format
Loading history...
159
160 4
        if (empty($login) || empty($transaction_key)) {
0 ignored issues
show
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
161 2
            throw new AuthnetInvalidCredentialsException('You have not configured your login credentials properly.');
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...
162
        }
163
164 2
        $base64credentials = base64_encode(sprintf('%s:%s', $login, $transaction_key));
0 ignored issues
show
Coding Style introduced by
Variable "base64credentials" contains numbers but this is discouraged
Loading history...
Coding Style introduced by
Variable "transaction_key" is not in valid camel caps format
Loading history...
165
166 2
        $curl = new Curl();
167 2
        $curl->setOpt(CURLOPT_RETURNTRANSFER, true);
0 ignored issues
show
Coding Style introduced by
TRUE, FALSE and NULL should be uppercase as per the configured coding-style; instead of true please use TRUE.
Loading history...
168 2
        $curl->setOpt(CURLOPT_SSL_VERIFYPEER, false);
0 ignored issues
show
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...
169 2
        $curl->setOpt(CURLOPT_HEADER, false);
0 ignored issues
show
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...
170 2
        $curl->setHeader('Content-Type', 'application/json');
171 2
        $curl->setHeader('Authorization', sprintf('Basic %s', $base64credentials));
0 ignored issues
show
Coding Style introduced by
Variable "base64credentials" contains numbers but this is discouraged
Loading history...
172
173 2
        $object = new AuthnetWebhooksRequest($api_url);
0 ignored issues
show
Coding Style introduced by
Variable "api_url" is not in valid camel caps format
Loading history...
174 2
        $object->setProcessHandler($curl);
175
176 2
        return $object;
177
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end getWebhooksHandler()
Loading history...
178
179
    /**
180
     * Gets the API endpoint to be used for a SIM API call.
181
     *
182
     * @param  int $server ID of which server to use
0 ignored issues
show
Coding Style introduced by
Expected "integer" but found "int" for parameter type
Loading history...
introduced by
Parameter comment must end with a full stop
Loading history...
183
     * @return string                  The URL endpoint the request is to be sent to
0 ignored issues
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
184
     * @throws AuthnetInvalidServerException
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...
185
     */
186 3
    protected static function getWebhooksURL(int $server): string
0 ignored issues
show
Coding Style introduced by
This method is not in camel caps format.

This check looks for method names that are not written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection seeker becomes databaseConnectionSeeker.

Loading history...
187
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
188
        $urls = [
189 3
            static::USE_PRODUCTION_SERVER  => 'https://api.authorize.net/rest/v1/',
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 17 spaces, but found 12.
Loading history...
190 3
            static::USE_DEVELOPMENT_SERVER => 'https://apitest.authorize.net/rest/v1/',
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 17 spaces, but found 12.
Loading history...
191
        ];
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 16 space(s), but found 8.
Loading history...
192 3
        if (array_key_exists($server, $urls)) {
193 2
            return $urls[$server];
194
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
195 1
        throw new AuthnetInvalidServerException('You did not provide a valid server.');
196
    }
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 getWebhooksURL()
Loading history...
197
}
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...
198