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

QueryRequest::setSortKeyConditionExpression()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 6
rs 10
ccs 5
cts 5
cp 1
cc 1
nc 1
nop 3
crap 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