PluginProbe
Media Cloud Sync / 1.2.10
Media Cloud Sync v1.2.10
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / Api / ErrorParser / JsonRpcErrorParser.php

JsonRpcErrorParser.php in Media Cloud Sync 1.2.10, at includes/sdk/s3/Aws/Api/ErrorParser/JsonRpcErrorParser.php

37 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\Api\ErrorParser;
4
5 use Dudlewebs\WPMCS\s3\Aws\Api\Parser\JsonParser;
6 use Dudlewebs\WPMCS\s3\Aws\Api\Service;
7 use Dudlewebs\WPMCS\s3\Aws\CommandInterface;
8 use Dudlewebs\WPMCS\s3\Psr\Http\Message\ResponseInterface;
9 /**
10 * Parsers JSON-RPC errors.
11 */
12 class JsonRpcErrorParser extends AbstractErrorParser
13 {
14 use JsonParserTrait;
15 private $parser;
16 public function __construct(Service $api = null, JsonParser $parser = null)
17 {
18 parent::__construct($api);
19 $this->parser = $parser ?: new JsonParser();
20 }
21 public function __invoke(ResponseInterface $response, CommandInterface $command = null)
22 {
23 $data = $this->genericHandler($response);
24 // Make the casing consistent across services.
25 if ($data['parsed']) {
26 $data['parsed'] = \array_change_key_case($data['parsed']);
27 }
28 if (isset($data['parsed']['__type'])) {
29 $parts = \explode('#', $data['parsed']['__type']);
30 $data['code'] = isset($parts[1]) ? $parts[1] : $parts[0];
31 $data['message'] = isset($data['parsed']['message']) ? $data['parsed']['message'] : null;
32 }
33 $this->populateShape($data, $response, $command);
34 return $data;
35 }
36 }
37