PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / vendor / vendor-prefixed / stellarwp / licensing-api-client / src / Http / JsonDecoder.php

JsonDecoder.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.9, at vendor/vendor-prefixed/stellarwp/licensing-api-client/src/Http/JsonDecoder.php

32 lines 747 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php declare(strict_types=1);
2
3 namespace Give\Vendors\LiquidWeb\LicensingApiClient\Http;
4
5 use JsonException;
6 use Give\Vendors\LiquidWeb\LicensingApiClient\Exceptions\DecodingException;
7
8 /**
9 * Decodes JSON response bodies into arrays for response mappers.
10 */
11 final class JsonDecoder
12 {
13 /**
14 *
15 * @throws DecodingException
16 * @return array<array-key, mixed>
17 */
18 public function decode(string $json): array {
19 try {
20 $decoded = json_decode($json, true, 512, JSON_THROW_ON_ERROR);
21 } catch (JsonException $exception) {
22 throw new DecodingException('Unable to decode JSON response.', 0, $exception);
23 }
24
25 if (!is_array($decoded)) {
26 throw new DecodingException('Decoded JSON response must be an array.');
27 }
28
29 return $decoded;
30 }
31 }
32