Completed
Push — master ( 3fc402...ee9403 )
by Guillermo A.
02:19
created

DeleteTableOperation::execute()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 10
ccs 5
cts 7
cp 0.7143
rs 10
c 1
b 0
f 0
cc 3
nc 3
nop 0
crap 3.2098
1
<?php
2
3
namespace Guillermoandrae\DynamoDb\Operation;
4
5
use Aws\DynamoDb\Exception\DynamoDbException;
6
use Guillermoandrae\DynamoDb\Contract\AbstractTableAwareOperation;
7
use Guillermoandrae\DynamoDb\Exception;
8
use InvalidArgumentException;
9
10
/**
11
 * @link https://docs.aws.amazon.com/aws-sdk-php/v3/api/api-dynamodb-2012-08-10.html#deletetable
12
 */
13
final class DeleteTableOperation extends AbstractTableAwareOperation
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18 8
    public function execute(): bool
19
    {
20
        try {
21 8
            $this->client->deleteTable($this->toArray());
22
            //$this->client->waitUntil('TableExists', ['TableName' => $this->tableName]);
23 7
            return true;
24 1
        } catch (DynamoDbException $ex) {
25 1
            throw new Exception($ex->getMessage());
26
        } catch (InvalidArgumentException $ex) {
27
            throw new Exception('Bad key schema: ' . $ex->getMessage());
28
        }
29
    }
30
}
31