PluginProbe
Media Cloud Sync / 1.0.0
Media Cloud Sync v1.0.0
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 / Parser / RestJsonParser.php

RestJsonParser.php in Media Cloud Sync 1.0.0, at includes/sdk/s3/Aws/Api/Parser/RestJsonParser.php

40 lines 1.3 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\Parser;
4
5 use Dudlewebs\WPMCS\s3\Aws\Api\Service;
6 use Dudlewebs\WPMCS\s3\Aws\Api\StructureShape;
7 use Dudlewebs\WPMCS\s3\Psr\Http\Message\ResponseInterface;
8 use Dudlewebs\WPMCS\s3\Psr\Http\Message\StreamInterface;
9 /**
10 * @internal Implements REST-JSON parsing (e.g., Glacier, Elastic Transcoder)
11 */
12 class RestJsonParser extends AbstractRestParser
13 {
14 use PayloadParserTrait;
15 /**
16 * @param Service $api Service description
17 * @param JsonParser $parser JSON body builder
18 */
19 public function __construct(Service $api, JsonParser $parser = null)
20 {
21 parent::__construct($api);
22 $this->parser = $parser ?: new JsonParser();
23 }
24 protected function payload(ResponseInterface $response, StructureShape $member, array &$result)
25 {
26 $jsonBody = $this->parseJson($response->getBody(), $response);
27 if ($jsonBody) {
28 $result += $this->parser->parse($member, $jsonBody);
29 }
30 }
31 public function parseMemberFromStream(StreamInterface $stream, StructureShape $member, $response)
32 {
33 $jsonBody = $this->parseJson($stream, $response);
34 if ($jsonBody) {
35 return $this->parser->parse($member, $jsonBody);
36 }
37 return [];
38 }
39 }
40