Completed
Push — master ( 0c808d...cd48f7 )
by Guillermo A.
02:23
created

ScanOperation   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 3
b 0
f 0
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 11 3
1
<?php
2
3
namespace Guillermoandrae\DynamoDb\Operation;
4
5
use Aws\DynamoDb\Exception\DynamoDbException;
6
use Guillermoandrae\Common\Collection;
7
use Guillermoandrae\Common\CollectionInterface;
8
use Guillermoandrae\DynamoDb\Contract\AbstractSearchOperation;
9
use Guillermoandrae\DynamoDb\Factory\ExceptionFactory;
10
11
/**
12
 * @link https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-dynamodb-2012-08-10.html#scan
13
 */
14
final class ScanOperation extends AbstractSearchOperation
15
{
16
    /**
17
     * {@inheritDoc}
18
     */
19 3
    public function execute(): CollectionInterface
20
    {
21
        try {
22 3
            $results = $this->client->scan($this->toArray());
23 2
            $rows = [];
24 2
            foreach ($results['Items'] as $item) {
25 1
                $rows[] = $this->marshaler->unmarshalItem($item);
26
            }
27 2
            return Collection::make($rows);
28 1
        } catch (DynamoDbException $ex) {
29 1
            throw ExceptionFactory::factory($ex);
30
        }
31
    }
32
}
33