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

DeleteTableOperation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 55.56%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 10
c 1
b 0
f 0
dl 0
loc 17
rs 10
ccs 5
cts 9
cp 0.5556

1 Method

Rating   Name   Duplication   Size   Complexity  
A execute() 0 12 4
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
        } catch (\Exception $ex) {
29
            die($ex->getMessage());
0 ignored issues
show
Bug Best Practice introduced by
In this branch, the function will implicitly return null which is incompatible with the type-hinted return boolean. Consider adding a return statement or allowing null as return value.

For hinted functions/methods where all return statements with the correct type are only reachable via conditions, ?null? gets implicitly returned which may be incompatible with the hinted type. Let?s take a look at an example:

interface ReturnsInt {
    public function returnsIntHinted(): int;
}

class MyClass implements ReturnsInt {
    public function returnsIntHinted(): int
    {
        if (foo()) {
            return 123;
        }
        // here: null is implicitly returned
    }
}
Loading history...
Best Practice introduced by
Using exit here is not recommended.

In general, usage of exit should be done with care and only when running in a scripting context like a CLI script.

Loading history...
30
        }
31
    }
32
}
33