| Conditions | 4 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 77 | 3 | public function getClient(): Redis |
|
| 78 | { |
||
| 79 | 3 | if (is_null($this->instance)) { |
|
| 80 | try { |
||
| 81 | 3 | $this->instance = new Redis(); |
|
| 82 | 3 | $con = @$this->instance->connect($this->host, $this->port); |
|
| 83 | 1 | if (false === $con) { |
|
| 84 | 1 | throw new \RedisException('Connection refused', 2); |
|
| 85 | } |
||
| 86 | 2 | } catch (\RedisException $e) { |
|
| 87 | 2 | $this->error = true; |
|
| 88 | 2 | $this->errorMessage = $e->getMessage(); |
|
| 89 | 2 | $this->errorCode = 1; |
|
| 90 | } |
||
| 91 | } |
||
| 92 | 3 | return $this->instance; |
|
| 93 | } |
||
| 139 |