stymiee /
authnetjson
| Conditions | 1 |
| Paths | 1 |
| Total Lines | 3 |
| Code Lines | 1 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 2 |
| CRAP Score | 1 |
| Changes | 0 | ||
| Metric | Value |
|---|---|
| cc | 1 |
| eloc | 1 |
| nc | 1 |
| nop | 0 |
| dl | 0 |
| loc | 3 |
| ccs | 2 |
| cts | 2 |
| cp | 1 |
| crap | 1 |
| rs | 10 |
| c | 0 |
| b | 0 |
| f | 0 |
| 1 | <?php |
||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | /** |
||
|
0 ignored issues
–
show
|
|||
| 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 | |||
| 18 | /** |
||
| 19 | * Creates a request to the Authorize.Net Webhooks 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/features/webhooks.html |
||
| 27 | */ |
||
| 28 | class AuthnetWebhooksRequest |
||
| 29 | { |
||
|
0 ignored issues
–
show
|
|||
| 30 | /** |
||
|
0 ignored issues
–
show
|
|||
| 31 | * @var string Base URL for processing a webhook |
||
| 32 | */ |
||
| 33 | private $url; |
||
|
0 ignored issues
–
show
|
|||
| 34 | |||
| 35 | /** |
||
|
0 ignored issues
–
show
|
|||
| 36 | * @var string Endpoint for processing a webhook |
||
| 37 | */ |
||
| 38 | private $endpoint; |
||
|
0 ignored issues
–
show
|
|||
| 39 | |||
| 40 | /** |
||
|
0 ignored issues
–
show
|
|||
| 41 | * @var string JSON formatted API request |
||
| 42 | */ |
||
| 43 | private $requestJson; |
||
|
0 ignored issues
–
show
|
|||
| 44 | |||
| 45 | /** |
||
|
0 ignored issues
–
show
|
|||
| 46 | * @var object Wrapper object representing an endpoint |
||
| 47 | */ |
||
| 48 | private $processor; |
||
|
0 ignored issues
–
show
|
|||
| 49 | |||
| 50 | /** |
||
| 51 | * Creates the request object by setting the Authorize.Net credentials and URL of the endpoint to be used |
||
|
0 ignored issues
–
show
|
|||
| 52 | * for the API call |
||
| 53 | * |
||
| 54 | * @param string $api_url URL endpoint for processing a transaction |
||
|
0 ignored issues
–
show
|
|||
| 55 | */ |
||
| 56 | 1 | public function __construct($api_url) |
|
|
0 ignored issues
–
show
|
|||
| 57 | { |
||
|
0 ignored issues
–
show
|
|||
| 58 | 1 | $this->url = $api_url; |
|
|
0 ignored issues
–
show
|
|||
| 59 | 1 | } |
|
|
0 ignored issues
–
show
|
|||
| 60 | |||
| 61 | /** |
||
| 62 | * Outputs the account credentials, endpoint URL, and request JSON in a human readable format |
||
| 63 | * |
||
| 64 | * @return string HTML table containing debugging information |
||
| 65 | */ |
||
| 66 | 2 | public function __toString() |
|
| 67 | { |
||
|
0 ignored issues
–
show
|
|||
| 68 | 2 | $output = '<table id="authnet-request">'."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 69 | 2 | $output .= '<caption>Authorize.Net Request</caption>'."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 70 | 2 | $output .= '<tr><th colspan="2"><b>Class Parameters</b></th></tr>'."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 71 | 2 | $output .= '<tr><td><b>Authnet Server URL</b></td><td>'.$this->url.'</td></tr>'."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 72 | 2 | $output .= '<tr><th colspan="2"><b>Request JSON</b></th></tr>'."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 73 | 2 | if (!empty($this->requestJson)) { |
|
|
0 ignored issues
–
show
|
|||
| 74 | 1 | $output .= '<tr><td colspan="2"><pre>'."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 75 | 1 | $output .= $this->requestJson."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 76 | 1 | $output .= '</pre></td></tr>'."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 77 | } else { |
||
| 78 | 1 | $output .= '<tr><td colspan="2" style="text-align: center;"><pre>N/A</pre></td></tr>'."\n"; |
|
|
0 ignored issues
–
show
|
|||
| 79 | } |
||
|
0 ignored issues
–
show
|
|||
| 80 | 2 | $output .= '</table>'; |
|
| 81 | |||
| 82 | 2 | return $output; |
|
| 83 | } |
||
|
0 ignored issues
–
show
|
|||
| 84 | |||
| 85 | /** |
||
| 86 | * Creates a new webhook |
||
| 87 | * |
||
| 88 | * @param array $webhooks Array of webhooks to be created or modified |
||
|
0 ignored issues
–
show
|
|||
| 89 | * @param string $webhookUrl URL of where webhook notifications will be sent |
||
|
0 ignored issues
–
show
|
|||
| 90 | * @param string $status Status of webhooks to be created or modified [active/inactive] |
||
|
0 ignored issues
–
show
|
|||
| 91 | * @return AuthnetWebhooksResponse |
||
|
0 ignored issues
–
show
|
|||
| 92 | * @throws AuthnetInvalidJsonException |
||
|
0 ignored issues
–
show
|
|||
| 93 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 94 | */ |
||
| 95 | 1 | public function createWebhooks(array $webhooks, string $webhookUrl, string $status = 'active'): object |
|
|
0 ignored issues
–
show
|
|||
| 96 | { |
||
|
0 ignored issues
–
show
|
|||
| 97 | 1 | $this->endpoint = 'webhooks'; |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 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...
|
|||
| 98 | 1 | $this->url = sprintf('%s%s', $this->url, $this->endpoint); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 9 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...
|
|||
| 99 | $request = [ |
||
|
0 ignored issues
–
show
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...
|
|||
| 100 | 1 | 'url' => $webhookUrl, |
|
|
0 ignored issues
–
show
|
|||
| 101 | 1 | 'eventTypes' => $webhooks, |
|
|
0 ignored issues
–
show
|
|||
| 102 | 1 | 'status' => $status |
|
|
0 ignored issues
–
show
|
|||
| 103 | ]; |
||
|
0 ignored issues
–
show
|
|||
| 104 | 1 | $this->requestJson = json_encode($request); |
|
| 105 | 1 | $response = $this->post($this->url, $this->requestJson); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 10 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...
|
|||
| 106 | 1 | return new AuthnetWebhooksResponse($response); |
|
| 107 | } |
||
|
0 ignored issues
–
show
|
|||
| 108 | |||
| 109 | /** |
||
| 110 | * Sends a test ping to a URL for (a) designated webhook(s) |
||
| 111 | * |
||
| 112 | * @param string $webhookId Webhook ID to be tested |
||
|
0 ignored issues
–
show
|
|||
| 113 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 114 | */ |
||
|
0 ignored issues
–
show
|
|||
| 115 | 1 | public function testWebhook(string $webhookId): void |
|
| 116 | { |
||
|
0 ignored issues
–
show
|
|||
| 117 | 1 | $this->endpoint = 'webhooks'; |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 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...
|
|||
| 118 | 1 | $this->url = sprintf('%s%s/%s/pings', $this->url, $this->endpoint, $webhookId); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 9 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...
|
|||
| 119 | 1 | $this->requestJson = json_encode([]); |
|
| 120 | 1 | $this->post($this->url, $this->requestJson); |
|
| 121 | 1 | } |
|
|
0 ignored issues
–
show
|
|||
| 122 | |||
| 123 | /** |
||
| 124 | * Gets all of the available event types |
||
| 125 | * |
||
| 126 | * @return AuthnetWebhooksResponse |
||
| 127 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 128 | * @throws AuthnetInvalidJsonException |
||
|
0 ignored issues
–
show
|
|||
| 129 | */ |
||
| 130 | 1 | public function getEventTypes(): object |
|
| 131 | { |
||
|
0 ignored issues
–
show
|
|||
| 132 | 1 | $this->endpoint = 'eventtypes'; |
|
| 133 | 1 | $this->url = sprintf('%s%s', $this->url, $this->endpoint); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 134 | 1 | return $this->getByUrl($this->url); |
|
| 135 | } |
||
|
0 ignored issues
–
show
|
|||
| 136 | |||
| 137 | /** |
||
| 138 | * List all of your webhooks |
||
| 139 | * |
||
| 140 | * @return AuthnetWebhooksResponse |
||
| 141 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 142 | * @throws AuthnetInvalidJsonException |
||
|
0 ignored issues
–
show
|
|||
| 143 | */ |
||
| 144 | 1 | public function getWebhooks(): object |
|
| 145 | { |
||
|
0 ignored issues
–
show
|
|||
| 146 | 1 | $this->endpoint = 'webhooks'; |
|
| 147 | 1 | $this->url = sprintf('%s%s', $this->url, $this->endpoint); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 148 | 1 | return $this->getByUrl($this->url); |
|
| 149 | } |
||
|
0 ignored issues
–
show
|
|||
| 150 | |||
| 151 | /** |
||
| 152 | * Get a webhook |
||
| 153 | * |
||
| 154 | * @param string $webhookId Webhook ID to be retrieved |
||
|
0 ignored issues
–
show
|
|||
| 155 | * @return AuthnetWebhooksResponse |
||
|
0 ignored issues
–
show
|
|||
| 156 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 157 | * @throws AuthnetInvalidJsonException |
||
|
0 ignored issues
–
show
|
|||
| 158 | */ |
||
| 159 | 1 | public function getWebhook(string $webhookId): object |
|
| 160 | { |
||
|
0 ignored issues
–
show
|
|||
| 161 | 1 | $this->endpoint = 'webhooks'; |
|
| 162 | 1 | $this->url = sprintf('%s%s/%s', $this->url, $this->endpoint, $webhookId); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 163 | 1 | return $this->getByUrl($this->url); |
|
| 164 | } |
||
|
0 ignored issues
–
show
|
|||
| 165 | |||
| 166 | /** |
||
| 167 | * GET API request |
||
| 168 | * |
||
| 169 | * @param string $url API endpoint to hit |
||
|
0 ignored issues
–
show
|
|||
| 170 | * @return object |
||
|
0 ignored issues
–
show
|
|||
| 171 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 172 | * @throws AuthnetInvalidJsonException |
||
|
0 ignored issues
–
show
|
|||
| 173 | */ |
||
| 174 | 3 | private function getByUrl(string $url): object |
|
|
0 ignored issues
–
show
|
|||
| 175 | { |
||
|
0 ignored issues
–
show
|
|||
| 176 | 3 | $response = $this->get($url); |
|
| 177 | 3 | return new AuthnetWebhooksResponse($response); |
|
| 178 | } |
||
|
0 ignored issues
–
show
|
|||
| 179 | |||
| 180 | /** |
||
| 181 | * Updates webhook event types |
||
| 182 | * |
||
| 183 | * @param string $webhookId Webhook ID to be modified |
||
|
0 ignored issues
–
show
|
|||
| 184 | * @param string $webhookUrl URL of where webhook notifications will be sent |
||
|
0 ignored issues
–
show
|
|||
| 185 | * @param array $eventTypes Array of event types to be added/removed |
||
|
0 ignored issues
–
show
|
|||
| 186 | * @param string $status Status of webhooks to be modified [active/inactive] |
||
|
0 ignored issues
–
show
|
|||
| 187 | * @return AuthnetWebhooksResponse |
||
|
0 ignored issues
–
show
|
|||
| 188 | * @throws AuthnetInvalidJsonException |
||
|
0 ignored issues
–
show
|
|||
| 189 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 190 | */ |
||
| 191 | 1 | public function updateWebhook(string $webhookId, string $webhookUrl, array $eventTypes, string $status = 'active'): object |
|
|
0 ignored issues
–
show
|
|||
| 192 | { |
||
|
0 ignored issues
–
show
|
|||
| 193 | 1 | $this->endpoint = 'webhooks'; |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 4 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...
|
|||
| 194 | 1 | $this->url = sprintf('%s%s/%s', $this->url, $this->endpoint, $webhookId); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 9 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...
|
|||
| 195 | $request = [ |
||
|
0 ignored issues
–
show
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...
|
|||
| 196 | 1 | 'url' => $webhookUrl, |
|
|
0 ignored issues
–
show
|
|||
| 197 | 1 | 'eventTypes' => $eventTypes, |
|
|
0 ignored issues
–
show
|
|||
| 198 | 1 | 'status' => $status |
|
|
0 ignored issues
–
show
|
|||
| 199 | ]; |
||
|
0 ignored issues
–
show
|
|||
| 200 | 1 | $this->requestJson = json_encode($request); |
|
| 201 | 1 | $response = $this->put($this->url, $this->requestJson); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 10 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...
|
|||
| 202 | 1 | return new AuthnetWebhooksResponse($response); |
|
| 203 | } |
||
|
0 ignored issues
–
show
|
|||
| 204 | |||
| 205 | /** |
||
| 206 | * Delete a webhook |
||
| 207 | * |
||
| 208 | * @param string $webhookId Webhook ID to be deleted |
||
|
0 ignored issues
–
show
|
|||
| 209 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 210 | */ |
||
|
0 ignored issues
–
show
|
|||
| 211 | 1 | public function deleteWebhook(string $webhookId): void |
|
| 212 | { |
||
|
0 ignored issues
–
show
|
|||
| 213 | 1 | $this->endpoint = 'webhooks'; |
|
| 214 | 1 | $this->url = sprintf('%s%s/%s', $this->url, $this->endpoint, $webhookId); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 215 | 1 | $this->delete($this->url); |
|
| 216 | 1 | } |
|
|
0 ignored issues
–
show
|
|||
| 217 | |||
| 218 | /** |
||
| 219 | * Retrieve Notification History |
||
| 220 | * |
||
| 221 | * @param int $limit Default: 1000 |
||
|
0 ignored issues
–
show
|
|||
| 222 | * @param int $offset Default: 0 |
||
|
0 ignored issues
–
show
|
|||
| 223 | * @return AuthnetWebhooksResponse |
||
|
0 ignored issues
–
show
|
|||
| 224 | * @throws AuthnetInvalidJsonException |
||
|
0 ignored issues
–
show
|
|||
| 225 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 226 | */ |
||
| 227 | 1 | public function getNotificationHistory(int $limit = 1000, int $offset = 0): object |
|
|
0 ignored issues
–
show
|
|||
| 228 | { |
||
|
0 ignored issues
–
show
|
|||
| 229 | 1 | $this->endpoint = 'notifications'; |
|
| 230 | 1 | $this->url = sprintf('%s%s', $this->url, $this->endpoint); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 231 | 1 | $response = $this->get( |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 7 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...
|
|||
| 232 | 1 | $this->url, [ |
|
| 233 | 1 | 'offset' => $offset, |
|
|
0 ignored issues
–
show
|
|||
| 234 | 1 | 'limit' => $limit |
|
|
0 ignored issues
–
show
|
|||
| 235 | ] |
||
|
0 ignored issues
–
show
|
|||
| 236 | ); |
||
| 237 | 1 | return new AuthnetWebhooksResponse($response); |
|
| 238 | } |
||
|
0 ignored issues
–
show
|
|||
| 239 | |||
| 240 | /** |
||
| 241 | * Tells the handler to make the API call to Authorize.Net |
||
| 242 | * |
||
| 243 | * @return string |
||
| 244 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 245 | */ |
||
| 246 | 4 | private function handleResponse(): string |
|
|
0 ignored issues
–
show
|
|||
| 247 | { |
||
|
0 ignored issues
–
show
|
|||
| 248 | 4 | if (!$this->processor->error) { |
|
|
0 ignored issues
–
show
|
|||
| 249 | 1 | return $this->processor->response; |
|
| 250 | } |
||
|
0 ignored issues
–
show
|
|||
| 251 | 3 | $response = json_decode($this->processor->response, false); |
|
|
0 ignored issues
–
show
Equals sign not aligned with surrounding assignments; expected 6 spaces but found 1 space
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line. To visualize $a = "a";
$ab = "ab";
$abc = "abc";
will produce issues in the first and second line, while this second example $a = "a";
$ab = "ab";
$abc = "abc";
will produce no issues. Loading history...
|
|||
| 252 | 3 | $error_message = sprintf('(%u) %s: %s', $response->status, $response->reason, $response->message); |
|
|
0 ignored issues
–
show
|
|||
| 253 | |||
| 254 | 3 | throw new AuthnetCurlException(sprintf('Connection error: %s', $error_message)); |
|
|
0 ignored issues
–
show
|
|||
| 255 | } |
||
|
0 ignored issues
–
show
|
|||
| 256 | |||
| 257 | /** |
||
| 258 | * Make GET request via Curl |
||
| 259 | * |
||
| 260 | * @param string $url |
||
|
0 ignored issues
–
show
|
|||
| 261 | * @param array $params |
||
|
0 ignored issues
–
show
|
|||
| 262 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 263 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 264 | * |
||
| 265 | * @codeCoverageIgnore |
||
| 266 | */ |
||
| 267 | private function get(string $url, array $params = []): string |
||
|
0 ignored issues
–
show
|
|||
| 268 | { |
||
|
0 ignored issues
–
show
|
|||
| 269 | $this->processor->get($url, $params); |
||
| 270 | return $this->handleResponse(); |
||
| 271 | } |
||
|
0 ignored issues
–
show
|
|||
| 272 | |||
| 273 | /** |
||
| 274 | * Make POST request via Curl |
||
| 275 | * |
||
| 276 | * @param string $url API endpoint |
||
|
0 ignored issues
–
show
|
|||
| 277 | * @param string $request JSON request payload |
||
|
0 ignored issues
–
show
|
|||
| 278 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 279 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 280 | * |
||
| 281 | * @codeCoverageIgnore |
||
| 282 | */ |
||
| 283 | private function post(string $url, string $request): string |
||
|
0 ignored issues
–
show
|
|||
| 284 | { |
||
|
0 ignored issues
–
show
|
|||
| 285 | $this->processor->post($url, $request); |
||
| 286 | return $this->handleResponse(); |
||
| 287 | } |
||
|
0 ignored issues
–
show
|
|||
| 288 | |||
| 289 | /** |
||
| 290 | * Make PUT request via Curl |
||
| 291 | * |
||
| 292 | * @param string $url API endpoint |
||
|
0 ignored issues
–
show
|
|||
| 293 | * @param string $request JSON request payload |
||
|
0 ignored issues
–
show
|
|||
| 294 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 295 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 296 | * |
||
| 297 | * @codeCoverageIgnore |
||
| 298 | */ |
||
| 299 | private function put(string $url, string $request): string |
||
|
0 ignored issues
–
show
|
|||
| 300 | { |
||
|
0 ignored issues
–
show
|
|||
| 301 | $this->processor->put($url, $request, true); |
||
|
0 ignored issues
–
show
|
|||
| 302 | return $this->handleResponse(); |
||
| 303 | } |
||
|
0 ignored issues
–
show
|
|||
| 304 | |||
| 305 | /** |
||
| 306 | * Make DELETE request via Curl |
||
| 307 | * |
||
| 308 | * @param string $url API endpoint |
||
|
0 ignored issues
–
show
|
|||
| 309 | * @return string |
||
|
0 ignored issues
–
show
|
|||
| 310 | * @throws AuthnetCurlException |
||
|
0 ignored issues
–
show
|
|||
| 311 | * |
||
| 312 | * @codeCoverageIgnore |
||
| 313 | */ |
||
| 314 | private function delete(string $url): string |
||
|
0 ignored issues
–
show
|
|||
| 315 | { |
||
|
0 ignored issues
–
show
|
|||
| 316 | $this->processor->delete($url, [], true); |
||
|
0 ignored issues
–
show
|
|||
| 317 | return $this->handleResponse(); |
||
| 318 | } |
||
|
0 ignored issues
–
show
|
|||
| 319 | |||
| 320 | /** |
||
| 321 | * 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
|
|||
| 322 | * |
||
| 323 | * @param Curl $processor |
||
|
0 ignored issues
–
show
|
|||
| 324 | */ |
||
|
0 ignored issues
–
show
|
|||
| 325 | 1 | public function setProcessHandler(Curl $processor): void |
|
| 326 | { |
||
|
0 ignored issues
–
show
|
|||
| 327 | 1 | $this->processor = $processor; |
|
| 328 | 1 | } |
|
|
0 ignored issues
–
show
|
|||
| 329 | |||
| 330 | /** |
||
| 331 | * Gets the request sent to Authorize.Net in JSON format for logging purposes |
||
| 332 | * |
||
| 333 | * @return string transaction request sent to Authorize.Net in JSON format |
||
| 334 | */ |
||
| 335 | 1 | public function getRawRequest(): string |
|
| 336 | { |
||
|
0 ignored issues
–
show
|
|||
| 337 | 1 | return $this->requestJson; |
|
| 338 | } |
||
|
0 ignored issues
–
show
|
|||
| 339 | } |
||
|
0 ignored issues
–
show
|
|||
| 340 |