Skip to content

Commit

Permalink
Cleanup to use readonly properties
Browse files Browse the repository at this point in the history
  • Loading branch information
cspray committed Apr 5, 2024
1 parent 36f9bc9 commit 7459886
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions src/PdoConnectionAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@

namespace Cspray\DatabaseTestCase;

use Cspray\DatabaseTestCase\DatabaseRepresentation\Row;
use Cspray\DatabaseTestCase\DatabaseRepresentation\Table;
use Cspray\DatabaseTestCase\Exception\UnableToGetTable;
use Closure;
use Cspray\DatabaseTestCase\Exception\MissingRequiredExtension;
use PDO;
use PDOException;

if (! extension_loaded('pdo')) {
throw new MissingRequiredExtension('You must enable ext-pdo to use the ' . PdoConnectionAdapter::class);
Expand All @@ -17,15 +14,10 @@ final class PdoConnectionAdapter extends AbstractConnectionAdapter {

private ?PDO $connection = null;

/** @var callable */
private $pdoSupplier;

private readonly PdoDriver $pdoDriver;

private function __construct(callable $pdoSupplier, PdoDriver $pdoDriver) {
$this->pdoSupplier = $pdoSupplier;
$this->pdoDriver = $pdoDriver;
}
private function __construct(
private readonly Closure $pdoSupplier,
private readonly PdoDriver $pdoDriver
) {}

public static function fromConnectionConfig(ConnectionAdapterConfig $adapterConfig, PdoDriver $pdoDriver) : self {
return self::fromExistingConnection(new PDO($pdoDriver->dsn($adapterConfig)), $pdoDriver);
Expand Down

0 comments on commit 7459886

Please sign in to comment.