Completed
Push — master ( 8f800b...a10bf5 )
by Biao
03:46
created

ConnectionFactory   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A createConnector() 0 11 3
A createConnection() 0 7 2
1
<?php
2
3
namespace Hhxsv5\LaravelS\Illuminate\Database;
4
5
use Hhxsv5\LaravelS\Illuminate\Database\Connectors\CoroutineMySQLConnector;
6
use Illuminate\Database\Connectors\ConnectionFactory as IlluminateConnectionFactory;
7
8
class ConnectionFactory extends IlluminateConnectionFactory
9
{
10
    public function createConnector(array $config)
11
    {
12
        if (!isset($config['driver'])) {
13
            throw new \InvalidArgumentException('A driver must be specified.');
14
        }
15
16
        switch ($config['driver']) {
17
            case 'sw-co-mysql':
18
                return new CoroutineMySQLConnector();
19
        }
20
        return parent::createConnector($config);
21
    }
22
23
    protected function createConnection($driver, $connection, $database, $prefix = '', array $config = [])
24
    {
25
        switch ($driver) {
26
            case 'sw-co-mysql':
27
                return new CoroutineMySQLConnection($connection, $database, $prefix, $config);
28
        }
29
        return parent::createConnection($driver, $connection, $database, $prefix, $config);
30
    }
31
}