for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Guillermoandrae\DynamoDb\Operation;
use Aws\DynamoDb\Exception\DynamoDbException;
use Guillermoandrae\Common\Collection;
use Guillermoandrae\Common\CollectionInterface;
use Guillermoandrae\DynamoDb\Contract\AbstractSearchOperation;
use Guillermoandrae\DynamoDb\Factory\ExceptionFactory;
/**
* Scan operation.
*
* Note about offset and limit: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.Limit
* @author Guillermo A. Fisher <[email protected]>
* @link https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-dynamodb-2012-08-10.html#scan
*/
final class ScanOperation extends AbstractSearchOperation
{
public function execute(): CollectionInterface
try {
$results = $this->client->scan($this->toArray());
$rows = [];
foreach ($results['Items'] as $item) {
$rows[] = $this->marshaler->unmarshalItem($item);
}
return Collection::make($rows)->limit($this->offset);
} catch (DynamoDbException $ex) {
throw ExceptionFactory::factory($ex);