Completed
Push — master ( ad5fe7...e813ea )
by Guillermo A.
03:49
created

LimitAwareOperationTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setOffset() 0 4 1
A setLimit() 0 4 1
A toArray() 0 4 1
1
<?php
2
3
namespace Guillermoandrae\DynamoDb\Contract;
4
5
/**
6
 * Trait for limit aware operations.
7
 *
8
 * @author Guillermo A. Fisher <[email protected]>
9
 */
10
trait LimitAwareOperationTrait
11
{
12
    /**
13
     * @var int The result offset.
14
     */
15
    protected $offset = 0;
16
17
    /**
18
     * @var int|null The result limit.
19
     */
20
    protected $limit;
21
22
    /**
23
     * Registers the result offset with this object.
24
     *
25
     * @param integer $offset The result offset.
26
     * @return mixed An implementation of this trait.
27
     */
28 7
    final public function setOffset(int $offset)
29
    {
30 7
        $this->offset = $offset;
31 7
        return $this;
32
    }
33
34
    /**
35
     * Registers the result limit with this object.
36
     *
37
     * @param integer|null $limit The result limit.
38
     * @return mixed An implementation of this trait.
39
     */
40 9
    final public function setLimit(?int $limit)
41
    {
42 9
        $this->limit = $limit;
43 9
        return $this;
44
    }
45
46 3
    public function toArray(): array
47
    {
48
        return [
49 3
            'Limit' => $this->offset + $this->limit
50
        ];
51
    }
52
}
53