Conditions | 5 |
Paths | 38 |
Total Lines | 39 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
31 | public static function get(array $setting) |
||
32 | { |
||
33 | $instance = null; |
||
34 | |||
35 | try { |
||
36 | |||
37 | $host = '127.0.0.1'; |
||
38 | $port = 6379; |
||
39 | |||
40 | if (!empty($setting['host'])) { |
||
41 | $host = $setting['host']; |
||
42 | } |
||
43 | |||
44 | if (!empty($setting['port'])) { |
||
45 | $port = $setting['port']; |
||
46 | } |
||
47 | |||
48 | // Create a Redis instance. |
||
49 | $redis = new Redis(); |
||
50 | $redis->connect($host, $port); |
||
51 | |||
52 | if (!empty($setting['auth'])) { |
||
53 | // @codeCoverageIgnoreStart |
||
54 | $redis->auth($setting['auth']); |
||
55 | // @codeCoverageIgnoreEnd |
||
56 | } |
||
57 | |||
58 | // Use Redis data driver. |
||
59 | $instance = new RedisDriver($redis); |
||
60 | |||
61 | // @codeCoverageIgnoreStart |
||
62 | |||
63 | } catch(RedisException $e) { |
||
64 | echo $e->getMessage(); |
||
65 | } |
||
66 | |||
67 | // @codeCoverageIgnoreEnd |
||
68 | |||
69 | return $instance; |
||
70 | } |
||
71 | } |