These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Liip\FunctionalTestBundle\Factory; |
||
| 4 | |||
| 5 | use Doctrine\Bundle\DoctrineBundle\ConnectionFactory as BaseConnectionFactory; |
||
| 6 | use Doctrine\Common\EventManager; |
||
| 7 | use Doctrine\DBAL\Configuration; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Creates a connection taking the db name from the env with |
||
| 11 | * a unique number defined by current process ID. |
||
| 12 | */ |
||
| 13 | class ConnectionFactory extends BaseConnectionFactory |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * Create a connection by name. |
||
| 17 | * |
||
| 18 | * @param array $params |
||
| 19 | * @param Configuration $config |
||
| 20 | * @param EventManager $eventManager |
||
| 21 | * @param array $mappingTypes |
||
| 22 | * |
||
| 23 | * @return \Doctrine\DBAL\Connection |
||
| 24 | */ |
||
| 25 | public function createConnection(array $params, Configuration $config = null, EventManager $eventManager = null, array $mappingTypes = array()) |
||
| 26 | { |
||
| 27 | $dbName = $this->getDbNameFromEnv($params['dbname']); |
||
| 28 | |||
| 29 | if ($params['driver'] === 'pdo_sqlite') { |
||
| 30 | $params['path'] = str_replace('__DBNAME__', $dbName, $params['path']); |
||
| 31 | } else { |
||
| 32 | $params['dbname'] = $dbName; |
||
| 33 | } |
||
| 34 | |||
| 35 | return parent::createConnection($params, $config, $eventManager, $mappingTypes); |
||
| 36 | } |
||
| 37 | |||
| 38 | private function getDbNameFromEnv($dbName) |
||
|
0 ignored issues
–
show
|
|||
| 39 | { |
||
| 40 | return 'dbTest'.getenv('TEST_TOKEN'); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.