Completed
Push — master ( e15fb0...634cc5 )
by Guillermo A.
02:14
created

QueryRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 15
c 1
b 0
f 0
dl 0
loc 30
rs 10
ccs 14
cts 14
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 5 1
A setPartitionKeyConditionExpression() 0 6 1
A setSortKeyConditionExpression() 0 6 1
1
<?php
2
3
namespace Guillermoandrae\Db\DynamoDb;
4
5
final class QueryRequest extends AbstractSearchRequest
6
{
7
    private $queryFilter = [];
0 ignored issues
show
introduced by
The private property $queryFilter is not used, and could be removed.
Loading history...
8
    private $keyConditionExpression = '';
9
    private $keyConditions = [];
0 ignored issues
show
introduced by
The private property $keyConditions is not used, and could be removed.
Loading history...
10
11 2
    public function setPartitionKeyConditionExpression(string $keyName, string $operator, string $value): QueryRequest
12
    {
13 2
        $partitionKeyConditionExpression = $this->parseExpression($operator, $keyName);
14 2
        $this->addExpressionAttributeValue($keyName, $value);
15 2
        $this->keyConditionExpression = $partitionKeyConditionExpression;
16 2
        return $this;
17
    }
18
19 1
    public function setSortKeyConditionExpression(string $keyName, string $operator, string $value): QueryRequest
20
    {
21 1
        $sortKeyConditionExpression = $this->parseExpression($operator, $keyName);
22 1
        $this->addExpressionAttributeValue($keyName, $value);
23 1
        $this->keyConditionExpression .= ' AND ' . $sortKeyConditionExpression;
24 1
        return $this;
25
    }
26
27
    /**
28
     * {@inheritDoc}
29
     */
30 2
    public function get(): array
31
    {
32 2
        $query = parent::get();
33 2
        $query['KeyConditionExpression'] = $this->keyConditionExpression;
34 2
        return $query;
35
    }
36
}
37