DynamoDbCollection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 12
c 1
b 0
f 0
dl 0
loc 31
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A lastKey() 0 17 4
A __construct() 0 5 1
1
<?php
2
3
namespace BaoPham\DynamoDb;
4
5
use Illuminate\Database\Eloquent\Collection;
6
use BaoPham\DynamoDb\ConditionAnalyzer\Index;
7
8
class DynamoDbCollection extends Collection
9
{
10
    /**
11
     * @var \BaoPham\DynamoDb\ConditionAnalyzer\Index
12
     */
13
    private $conditionIndex = null;
14
15 92
    public function __construct(array $items = [], Index $conditionIndex = null)
16
    {
17 92
        parent::__construct($items);
18
19 92
        $this->conditionIndex = $conditionIndex;
20 92
    }
21
22 4
    public function lastKey()
23
    {
24 4
        $after = $this->last();
25
26 4
        if (empty($after)) {
27 4
            return null;
28
        }
29
30 4
        $afterKey = $after->getKeys();
31
32 4
        $attributes = $this->conditionIndex ? $this->conditionIndex->columns() : [];
33
34 4
        foreach ($attributes as $attribute) {
35 1
            $afterKey[$attribute] = $after->getAttribute($attribute);
36
        }
37
38 4
        return $afterKey;
39
    }
40
}
41