diff --git a/ChangeLog b/ChangeLog index a33ae28..8a33f67 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2024-12-06 Francois Suter (Idéative) + + * Automate documentation and code linting + 2024-12-02 Francois Suter (Idéative) * Clean up and improve documentation diff --git a/Classes/Database/DoctrineDbalConnection.php b/Classes/Database/DoctrineDbalConnection.php index 6476379..483a660 100644 --- a/Classes/Database/DoctrineDbalConnection.php +++ b/Classes/Database/DoctrineDbalConnection.php @@ -35,7 +35,6 @@ class DoctrineDbalConnection * * @param array $parameters Parameters needed to connect to the database * @throws DatabaseConnectionException - * @return void * @throws QueryErrorException */ public function connect(array $parameters = []): void @@ -43,7 +42,7 @@ public function connect(array $parameters = []): void $configuration = new Configuration(); if (array_key_exists('uri', $parameters)) { $connectionParameters = [ - 'url' => $parameters['uri'] + 'url' => $parameters['uri'], ]; } else { $connectionParameters = [ @@ -52,22 +51,22 @@ public function connect(array $parameters = []): void 'password' => $parameters['password'], 'host' => $parameters['server'], 'driver' => $parameters['driver'] ?? null, - 'driverClass' => $parameters['driverClass'] ?? null + 'driverClass' => $parameters['driverClass'] ?? null, ]; } try { $this->connection = DriverManager::getConnection( - $connectionParameters, - $configuration + $connectionParameters, + $configuration ); } catch (\Exception $e) { // Throw unified exception throw new DatabaseConnectionException( - sprintf( - 'Database connection failed (%s)', - $e->getMessage() - ), - 1491062456 + sprintf( + 'Database connection failed (%s)', + $e->getMessage() + ), + 1491062456 ); } @@ -75,14 +74,13 @@ public function connect(array $parameters = []): void if (!empty($parameters['init'])) { try { $this->connection->executeQuery($parameters['init']); - } - catch (\Throwable $e) { + } catch (\Throwable $e) { throw new QueryErrorException( - sprintf( - 'Failled executing "init" statement (%s)', - $e->getMessage() - ), - 1491379532 + sprintf( + 'Failled executing "init" statement (%s)', + $e->getMessage() + ), + 1491379532 ); } } @@ -101,14 +99,13 @@ public function query(string $sql, int $fetchMode = \PDO::FETCH_ASSOC): array { try { $result = $this->connection->executeQuery($sql); - } - catch (\Exception $e) { + } catch (\Exception $e) { throw new QueryErrorException( - sprintf( - 'Failled executing query (%s)', - $e->getMessage() - ), - 1491379701 + sprintf( + 'Failled executing query (%s)', + $e->getMessage() + ), + 1491379701 ); } @@ -118,4 +115,4 @@ public function query(string $sql, int $fetchMode = \PDO::FETCH_ASSOC): array default => $result->fetchAllAssociative(), }; } -} \ No newline at end of file +} diff --git a/Classes/Exception/DatabaseConnectionException.php b/Classes/Exception/DatabaseConnectionException.php index 4cd2a0f..c320353 100644 --- a/Classes/Exception/DatabaseConnectionException.php +++ b/Classes/Exception/DatabaseConnectionException.php @@ -1,4 +1,5 @@