| Total Complexity | 3 |
| Total Lines | 42 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | abstract class AbstractKeyAwareOperation extends AbstractItemOperation |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * @var array The primary key values to be used when retrieving items. |
||
| 12 | */ |
||
| 13 | protected $key; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * Registers the DynamoDb client, Marshaler, table name, and primary key 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 | * @param array $key The primary key values to be used when retrieving items. |
||
| 22 | */ |
||
| 23 | 4 | public function __construct(DynamoDbClient $client, Marshaler $marshaler, string $tableName, array $key) |
|
| 24 | { |
||
| 25 | 4 | parent::__construct($client, $marshaler, $tableName); |
|
| 26 | 4 | $this->setKey($key); |
|
| 27 | 4 | } |
|
| 28 | |||
| 29 | /** |
||
| 30 | * Registers the operation's primary key with this object. |
||
| 31 | * |
||
| 32 | * @param array $key The primary key values to be used when retrieving items. |
||
| 33 | * @return AbstractKeyAwareOperation An implementation of this abstract. |
||
| 34 | */ |
||
| 35 | 4 | public function setKey(array $key): AbstractKeyAwareOperation |
|
| 36 | { |
||
| 37 | 4 | $this->key = $this->marshaler->marshalItem($key); |
|
| 38 | 4 | return $this; |
|
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * {@inheritDoc} |
||
| 43 | */ |
||
| 44 | 4 | public function toArray(): array |
|
| 50 | ]; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |