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

AbstractKeyAwareRequest::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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