Completed
Push — master ( a7a349...3fc402 )
by Guillermo A.
03:23
created

AbstractTableAwareOperation::__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
c 0
b 0
f 0
dl 0
loc 4
rs 10
ccs 3
cts 3
cp 1
cc 1
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Guillermoandrae\DynamoDb\Contract;
4
5
use Aws\DynamoDb\DynamoDbClient;
6
use Aws\DynamoDb\Marshaler;
7
8
abstract class AbstractTableAwareOperation extends AbstractOperation
9
{
10
    /**
11
     * @var string The table name.
12
     */
13
    protected $tableName;
14
15
    /**
16
     * Registers the Marshaler and table name with this object.
17
     *
18
     * @param DynamoDbClient $client The DynamoDb client.
19
     * @param Marshaler $marshaler The Marshaler.
20
     * @param string $tableName The table name.
21
     */
22 39
    public function __construct(DynamoDbClient $client, Marshaler $marshaler, string $tableName)
23
    {
24 39
        parent::__construct($client, $marshaler);
25 39
        $this->setTableName($tableName);
26 39
    }
27
28
    /**
29
     * Registers the table name.
30
     *
31
     * @param string $tableName The table name.
32
     * @return OperationInterface An implementation of this interface.
33
     */
34 39
    final public function setTableName(string $tableName): OperationInterface
35
    {
36 39
        $this->tableName = $tableName;
37 39
        return $this;
38
    }
39
40
    /**
41
     * {@inheritDoc}
42
     */
43 34
    public function toArray(): array
44
    {
45
        return [
46 34
            'TableName' => $this->tableName,
47
        ];
48
    }
49
}
50