Skip to content

Commit 264c453

Browse files
authored
Merge pull request #6 from tyrsson/remove-migrated-exception-class
Removes a custom exception class that has been moved to php-db/phpdb and refactors DriverInterfaceFactory to use the new class.
2 parents 28df694 + 1782779 commit 264c453

File tree

4 files changed

+10
-33
lines changed

4 files changed

+10
-33
lines changed

src/Container/ConnectionInterfaceFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function __invoke(
3030
): ConnectionInterface&Connection {
3131
if (! is_array($options['connection']) || $options['connection'] === []) {
3232
throw new InvalidConnectionParametersException(
33-
'Connection configuration must be an array of parameters pased via $options["connection"]',
33+
'Connection configuration must be an array of parameters passed via $options["connection"]',
3434
$options['connection']
3535
);
3636
}

src/Container/DriverInterfaceFactory.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Laminas\ServiceManager\ServiceManager;
88
use PhpDb\Adapter\Driver\DriverInterface;
99
use PhpDb\Adapter\Pgsql;
10+
use PhpDb\Exception\ContainerException;
1011
use Psr\Container\ContainerInterface;
1112

1213
final class DriverInterfaceFactory
@@ -17,12 +18,13 @@ public function __invoke(
1718
?array $options = null
1819
): DriverInterface {
1920
if (! $options['connection']) {
20-
throw Pgsql\Exception\ContainerException::forServiceFailure(
21+
throw ContainerException::forService(
2122
Pgsql\Driver::class,
22-
self::class . ' can only be used via the ServiceManager\'s build() method
23-
with connection parameters passed via $options["connection"]'
23+
self::class,
24+
'$options["connection"] must contain an array of connection configuration.'
2425
);
2526
}
27+
2628
$connection = $container->build(Pgsql\Connection::class, $options);
2729
return new Pgsql\Driver(
2830
connection:$connection,

src/Container/PlatformInterfaceFactory.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66

77
use PhpDb\Adapter\Pgsql;
88
use PhpDb\Adapter\Platform\PlatformInterface;
9+
use PhpDb\Exception\ContainerException;
910
use Psr\Container\ContainerInterface;
1011

1112
final class PlatformInterfaceFactory
1213
{
1314
/**
14-
* @throws Pgsql\Exception\ContainerException
15+
* @throws ContainerException
1516
*/
1617
public function __invoke(
1718
ContainerInterface $container,
@@ -24,8 +25,9 @@ public function __invoke(
2425
&& ! $driver instanceof Pgsql\Pdo\Driver
2526
) {
2627
// todo: Once latest PR is merged for 0.5.0 update to use PhpDB\Exception\ContainerException
27-
throw Pgsql\Exception\ContainerException::forServiceFailure(
28+
throw ContainerException::forService(
2829
PlatformInterface::class,
30+
self::class,
2931
'Invalid or missing driver provided'
3032
);
3133
}

src/Exception/ContainerException.php

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)