Skip to content

Commit 23e3c1e

Browse files
committed
[TASK] Clean up code with CS fixer
1 parent 26b1905 commit 23e3c1e

File tree

5 files changed

+33
-40
lines changed

5 files changed

+33
-40
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2024-12-06 Francois Suter (Idéative) <[email protected]>
2+
3+
* Automate documentation and code linting
4+
15
2024-12-02 Francois Suter (Idéative) <[email protected]>
26

37
* Clean up and improve documentation

Classes/Database/DoctrineDbalConnection.php

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,14 @@ class DoctrineDbalConnection
3535
*
3636
* @param array $parameters Parameters needed to connect to the database
3737
* @throws DatabaseConnectionException
38-
* @return void
3938
* @throws QueryErrorException
4039
*/
4140
public function connect(array $parameters = []): void
4241
{
4342
$configuration = new Configuration();
4443
if (array_key_exists('uri', $parameters)) {
4544
$connectionParameters = [
46-
'url' => $parameters['uri']
45+
'url' => $parameters['uri'],
4746
];
4847
} else {
4948
$connectionParameters = [
@@ -52,37 +51,36 @@ public function connect(array $parameters = []): void
5251
'password' => $parameters['password'],
5352
'host' => $parameters['server'],
5453
'driver' => $parameters['driver'] ?? null,
55-
'driverClass' => $parameters['driverClass'] ?? null
54+
'driverClass' => $parameters['driverClass'] ?? null,
5655
];
5756
}
5857
try {
5958
$this->connection = DriverManager::getConnection(
60-
$connectionParameters,
61-
$configuration
59+
$connectionParameters,
60+
$configuration
6261
);
6362
} catch (\Exception $e) {
6463
// Throw unified exception
6564
throw new DatabaseConnectionException(
66-
sprintf(
67-
'Database connection failed (%s)',
68-
$e->getMessage()
69-
),
70-
1491062456
65+
sprintf(
66+
'Database connection failed (%s)',
67+
$e->getMessage()
68+
),
69+
1491062456
7170
);
7271
}
7372

7473
// Execute connection initialization if defined
7574
if (!empty($parameters['init'])) {
7675
try {
7776
$this->connection->executeQuery($parameters['init']);
78-
}
79-
catch (\Throwable $e) {
77+
} catch (\Throwable $e) {
8078
throw new QueryErrorException(
81-
sprintf(
82-
'Failled executing "init" statement (%s)',
83-
$e->getMessage()
84-
),
85-
1491379532
79+
sprintf(
80+
'Failled executing "init" statement (%s)',
81+
$e->getMessage()
82+
),
83+
1491379532
8684
);
8785
}
8886
}
@@ -101,14 +99,13 @@ public function query(string $sql, int $fetchMode = \PDO::FETCH_ASSOC): array
10199
{
102100
try {
103101
$result = $this->connection->executeQuery($sql);
104-
}
105-
catch (\Exception $e) {
102+
} catch (\Exception $e) {
106103
throw new QueryErrorException(
107-
sprintf(
108-
'Failled executing query (%s)',
109-
$e->getMessage()
110-
),
111-
1491379701
104+
sprintf(
105+
'Failled executing query (%s)',
106+
$e->getMessage()
107+
),
108+
1491379701
112109
);
113110
}
114111

@@ -118,4 +115,4 @@ public function query(string $sql, int $fetchMode = \PDO::FETCH_ASSOC): array
118115
default => $result->fetchAllAssociative(),
119116
};
120117
}
121-
}
118+
}

Classes/Exception/DatabaseConnectionException.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Cobweb\SvconnectorSql\Exception;
34

45
/*
@@ -18,10 +19,5 @@
1819

1920
/**
2021
* Exception to be thrown when failing to connect to a DBMS.
21-
*
22-
* @package Cobweb\SvconnectorSql\Exception
2322
*/
24-
class DatabaseConnectionException extends SourceErrorException
25-
{
26-
27-
}
23+
class DatabaseConnectionException extends SourceErrorException {}

Classes/Exception/QueryErrorException.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
namespace Cobweb\SvconnectorSql\Exception;
34

45
/*
@@ -18,10 +19,5 @@
1819

1920
/**
2021
* Exception to be thrown when a SQL query fails.
21-
*
22-
* @package Cobweb\SvconnectorSql\Exception
2322
*/
24-
class QueryErrorException extends SourceErrorException
25-
{
26-
27-
}
23+
class QueryErrorException extends SourceErrorException {}

Classes/Service/ConnectorSql.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,10 @@
2222
use Cobweb\Svconnector\Event\ProcessRawDataEvent;
2323
use Cobweb\Svconnector\Event\ProcessResponseEvent;
2424
use Cobweb\Svconnector\Event\ProcessXmlDataEvent;
25-
use Cobweb\SvconnectorSql\Exception\DatabaseConnectionException;
26-
use Cobweb\SvconnectorSql\Exception\QueryErrorException;
2725
use Cobweb\Svconnector\Service\ConnectorBase;
2826
use Cobweb\SvconnectorSql\Database\DoctrineDbalConnection;
27+
use Cobweb\SvconnectorSql\Exception\DatabaseConnectionException;
28+
use Cobweb\SvconnectorSql\Exception\QueryErrorException;
2929
use TYPO3\CMS\Core\Utility\GeneralUtility;
3030

3131
/**
@@ -39,7 +39,7 @@ class ConnectorSql extends ConnectorBase
3939
/**
4040
* Verifies that the connection is functional
4141
* In this case it always is, as the connection can really be tested only for specific configurations
42-
* @return boolean TRUE if the service is available
42+
* @return bool TRUE if the service is available
4343
*/
4444
public function isAvailable(): bool
4545
{

0 commit comments

Comments
 (0)