Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/Api/ErrorParser/RpcV2CborErrorParser.php

raw symbols SCIP
1 <?php
2 namespace Aws\Api\ErrorParser;
3
4 use Aws\Api\Cbor\CborDecoder;
5 use Aws\Api\Parser\RpcV2ParserTrait;
6 use Aws\Api\Service;
7 use Aws\Api\StructureShape;
8 use Psr\Http\Message\ResponseInterface;
9 use Psr\Http\Message\StreamInterface;
10
11 /**
12 * Parses errors according to Smithy RPC V2 CBOR protocol standards.
13 *
14 * https://smithy.io/2.0/additional-specs/protocols/smithy-rpc-v2.html
15 *
16 * @internal
17 */
18 final class RpcV2CborErrorParser extends AbstractRpcV2ErrorParser
19 {
20 /** @var CborDecoder */
21 private CborDecoder $decoder;
22
23 use RpcV2ParserTrait;
24
25 /**
26 * @param Service|null $api
27 */
28 public function __construct(?Service $api = null)
29 {
30 $this->decoder = new CborDecoder();
31 parent::__construct($api);
32 }
33
34 /**
35 * @param ResponseInterface $response
36 * @param StructureShape $member
37 *
38 * @return array
39 * @throws \Exception
40 */
41 protected function payload(
42 ResponseInterface $response,
43 StructureShape $member
44 ): array
45 {
46 $body = $response->getBody();
47 $cborBody = $this->parseCbor($body, $response);
48
49 return $this->resolveOutputShape($member, $cborBody);
50 }
51
52 /**
53 * @param StreamInterface $body
54 * @param ResponseInterface $response
55 *
56 * @return mixed
57 */
58 protected function parseBody(
59 StreamInterface $body,
60 ResponseInterface $response
61 ): mixed
62 {
63 return $this->parseCbor($body, $response);
64 }
65 }