guillermoandrae /
php-dynamodb
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Guillermoandrae\DynamoDb\Operation; |
||
| 4 | |||
| 5 | use Aws\DynamoDb\Exception\DynamoDbException; |
||
| 6 | use Guillermoandrae\DynamoDb\Contract\AbstractItemOperation; |
||
| 7 | use Guillermoandrae\DynamoDb\Factory\ExceptionFactory; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * GetItem operation. |
||
| 11 | * |
||
| 12 | * @author Guillermo A. Fisher <[email protected]> |
||
| 13 | * @link https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-dynamodb-2012-08-10.html#getitem |
||
| 14 | */ |
||
| 15 | final class GetItemOperation extends AbstractItemOperation |
||
| 16 | { |
||
| 17 | 3 | public function execute(): array |
|
| 18 | { |
||
| 19 | try { |
||
| 20 | 3 | $item = []; |
|
| 21 | 3 | $results = $this->client->getItem($this->toArray()); |
|
| 22 | 2 | if (is_array($results['Item'])) { |
|
| 23 | 2 | $item = $this->getMarshaler()->unmarshalItem($results['Item'], false); |
|
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 24 | } |
||
| 25 | 2 | return $item; |
|
|
0 ignored issues
–
show
|
|||
| 26 | 1 | } catch (DynamoDbException $ex) { |
|
| 27 | 1 | throw ExceptionFactory::factory($ex); |
|
| 28 | } |
||
| 29 | } |
||
| 30 | } |
||
| 31 |