Skip to content

Commit 03a1347

Browse files
authored
Merge pull request #24 from php-etl/fix/connection-shared
Fix/connection shared
2 parents 86aa4c4 + eaed17e commit 03a1347

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

src/Factory/Connection.php

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -84,27 +84,25 @@ public function compile(array $config): SQL\Factory\Repository\Connection
8484

8585
$repository = new SQL\Factory\Repository\Connection($connection);
8686

87-
if (\array_key_exists('shared', $config) && true === $config['shared']) {
88-
$repository->addFiles(new File('PDOPool.php', new InMemory(<<<PHP
89-
<?php
90-
91-
namespace {$this->generatedNamespace};
92-
final class PDOPool {
93-
private static array \$connections = [];
94-
public static function unique(string \$dsn, ?string \$username = null, ?string \$password = null, \$options = []): \\PDO {
95-
return new \\PDO(\$dsn, \$username, \$password, \$options);
96-
}
97-
public static function shared(string \$dsn, ?string \$username = null, ?string \$password = null, \$options = []): \\PDO {
98-
if (isset(self::\$connections[\$dsn])) {
99-
return self::\$connections[\$dsn];
100-
}
101-
102-
return self::\$connections[\$dsn] = self::unique(\$dsn, \$username, \$password, \$options);
87+
$repository->addFiles(new File('PDOPool.php', new InMemory(<<<PHP
88+
<?php
89+
90+
namespace {$this->generatedNamespace};
91+
final class PDOPool {
92+
private static array \$connections = [];
93+
public static function unique(string \$dsn, ?string \$username = null, ?string \$password = null, \$options = []): \\PDO {
94+
return new \\PDO(\$dsn, \$username, \$password, \$options);
95+
}
96+
public static function shared(string \$dsn, ?string \$username = null, ?string \$password = null, \$options = []): \\PDO {
97+
if (isset(self::\$connections[\$dsn])) {
98+
return self::\$connections[\$dsn];
10399
}
100+
101+
return self::\$connections[\$dsn] = self::unique(\$dsn, \$username, \$password, \$options);
104102
}
105-
PHP
106-
)));
107-
}
103+
}
104+
PHP
105+
)));
108106

109107
return $repository;
110108
}

0 commit comments

Comments
 (0)