ScanOperation   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
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 13
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
 * Scan operation.
13
 *
14
 * Note about offset and limit: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html#Scan.Limit
15
 *
16
 * @author Guillermo A. Fisher <[email protected]>
17
 * @link https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-dynamodb-2012-08-10.html#scan
18
 */
19
final class ScanOperation extends AbstractSearchOperation
20
{
21 4
    public function execute(): CollectionInterface
22
    {
23
        try {
24 4
            $results = $this->client->scan($this->toArray());
25 3
            $rows = [];
26 3
            foreach ($results['Items'] as $item) {
27 2
                $rows[] = $this->marshaler->unmarshalItem($item);
28
            }
29 3
            return Collection::make($rows)->limit($this->offset);
30 1
        } catch (DynamoDbException $ex) {
31 1
            throw ExceptionFactory::factory($ex);
32
        }
33
    }
34
}
35