Вход Регистрация
Файл: sngine-v2.8/Script/includes/libs/AWS/Aws/Api/Parser/JsonRpcParser.php
Строк: 52
<?php
namespace AwsApiParser;

use 
AwsApiStructureShape;
use 
AwsApiService;
use 
AwsResult;
use 
AwsCommandInterface;
use 
PsrHttpMessageResponseInterface;
use 
PsrHttpMessageStreamInterface;

/**
 * @internal Implements JSON-RPC parsing (e.g., DynamoDB)
 */
class JsonRpcParser extends AbstractParser
{
    use 
PayloadParserTrait;

    
/**
     * @param Service    $api    Service description
     * @param JsonParser $parser JSON body builder
     */
    
public function __construct(Service $apiJsonParser $parser null)
    {
        
parent::__construct($api);
        
$this->parser $parser ?: new JsonParser();
    }

    public function 
__invoke(
        
CommandInterface $command,
        
ResponseInterface $response
    
) {
        
$operation $this->api->getOperation($command->getName());
        
$result null === $operation['output']
            ? 
null
            
$this->parseMemberFromStream(
                
$response->getBody(),
                
$operation->getOutput(),
                
$response
            
);

        return new 
Result($result ?: []);
    }

    public function 
parseMemberFromStream(
        
StreamInterface $stream,
        
StructureShape $member,
        
$response
    
) {
        return 
$this->parser->parse($member$this->parseJson($stream$response));
    }
}
Онлайн: 0
Реклама