Total Complexity | 10 |
Total Lines | 50 |
Duplicated Lines | 0 % |
Coverage | 84% |
Changes | 0 |
1 | <?php |
||
11 | abstract class AbstractPdoGateway |
||
12 | { |
||
13 | /** @var PDO */ |
||
14 | private $pdo; |
||
15 | |||
16 | /** @var PDOStatement[] */ |
||
17 | private $preparedStatements; |
||
18 | |||
19 | 23 | public function __construct(PDO $pdo) |
|
23 | 23 | } |
|
24 | |||
25 | 20 | public function preparedStatements(string $query): PDOStatement |
|
39 | } |
||
40 | |||
41 | 20 | public function executePrepared(string $query, array $arguments = [], string $exceptionMessage = ''): PDOStatement |
|
42 | { |
||
43 | 20 | $statement = $this->preparedStatements($query); |
|
44 | 20 | if (! $statement->execute($arguments)) { |
|
45 | $exceptionMessage = $exceptionMessage ? : 'Error retrieving data from database'; |
||
46 | throw new PersistenceException($exceptionMessage); |
||
47 | } |
||
48 | |||
49 | 20 | return $statement; |
|
50 | } |
||
51 | |||
52 | 8 | public function queryValue(string $query, array $arguments = [], $defaultValue = null) |
|
61 | } |
||
62 | } |
||
63 |