Completed
Push — master ( 20a668...02e94f )
by Guillermo A.
02:17
created

AbstractKeyAwareRequest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 10
dl 0
loc 41
c 0
b 0
f 0
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 6 1
A setKey() 0 4 1
A __construct() 0 4 1
1
<?php
2
3
namespace Guillermoandrae\DynamoDb;
4
5
use Aws\DynamoDb\Marshaler;
6
7
abstract class AbstractKeyAwareRequest extends AbstractItemRequest
8
{
9
    /**
10
     * @var array The primary key values to be used when retrieving items.
11
     */
12
    protected $key;
13
    
14
    /**
15
     * Registers the Marshaler, table name, and primary key with this object.
16
     *
17
     * @param Marshaler $marshaler The Marshaler.
18
     * @param string $tableName The table name.
19
     * @param array $key The primary key values to be used when retrieving items.
20
     */
21 4
    public function __construct(Marshaler $marshaler, string $tableName, array $key)
22
    {
23 4
        parent::__construct($marshaler, $tableName);
24 4
        $this->setKey($key);
25 4
    }
26
27
    /**
28
     * Registers the operation's primary key with this object.
29
     *
30
     * @param array $key The primary key values to be used when retrieving items.
31
     * @return AbstractKeyAwareRequest An implementation of this abstract.
32
     */
33 4
    public function setKey(array $key): AbstractKeyAwareRequest
34
    {
35 4
        $this->key = $this->marshaler->marshalItem($key);
36 4
        return $this;
37
    }
38
39
    /**
40
     * {@inheritDoc}
41
     */
42 4
    public function get(): array
43
    {
44
        return [
45 4
            'TableName' => $this->tableName,
46 4
            'ReturnConsumedCapacity' => $this->returnConsumedCapacity,
47 4
            'Key' => $this->key
48
        ];
49
    }
50
}
51