Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | public static function newInstance(string $dsn, string $user, string $password, string $slave): ConnectionLocator |
||
20 | { |
||
21 | $writes = ['master' => new Connection($dsn, $user, $password)]; |
||
22 | $i = 1; |
||
23 | $slaves = explode(',', $slave); |
||
24 | $reads = []; |
||
25 | foreach ($slaves as $host) { |
||
26 | $slaveDsn = self::changeHost($dsn, $host); |
||
27 | $name = 'slave' . (string) $i++; |
||
28 | $reads[$name] = new Connection($slaveDsn, $user, $password); |
||
29 | } |
||
30 | |||
31 | return new ConnectionLocator(null, $reads, $writes); |
||
32 | } |
||
46 |