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

PutItemRequest::__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
final class PutItemRequest extends AbstractItemRequest
8
{
9
    /**
10
     * @var array $item The item data.
11
     */
12
    private $item;
13
    
14
    /**
15
     * Registers the Marshaler, table name, and item data with this object.
16
     *
17
     * @param Marshaler $marshaler The Marshaler.
18
     * @param string $tableName The table name.
19
     * @param array $item The item data.
20
     */
21 7
    public function __construct(Marshaler $marshaler, string $tableName, array $item)
22
    {
23 7
        parent::__construct($marshaler, $tableName);
24 7
        $this->setItem($item);
25 7
    }
26
27
    /**
28
     * Registers the item data with this object.
29
     *
30
     * @param array $item The item data.
31
     * @return PutItemRequest This object.
32
     */
33 7
    public function setItem(array $item): PutItemRequest
34
    {
35 7
        $this->item = $this->marshaler->marshalItem($item);
36 7
        return $this;
37
    }
38
39
    /**
40
     * {@inheritDoc}
41
     */
42 7
    public function get(): array
43
    {
44
        return [
45 7
            'TableName' => $this->tableName,
46 7
            'Item' => $this->item,
47
        ];
48
    }
49
}
50