Redis::getClient()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Source\Core;
4
5
use Predis\Client;
0 ignored issues
show
Bug introduced by
The type Predis\Client was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Predis\Autoloader;
0 ignored issues
show
Bug introduced by
The type Predis\Autoloader was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
final class Redis
9
{
10
    private $client;
11
12
    public function __construct()
13
    {
14
        Autoloader::register();
15
16
        $this->client = new Client([
17
            'scheme' => CONF_REDIS_SCHEME,
18
            'host'   => CONF_REDIS_HOST,
19
            'port'   => CONF_REDIS_PORT,
20
        ]);
21
    }
22
23
    public function getClient(): Client
24
    {
25
        return $this->client;
26
    }
27
28
    public function __destruct()
29
    {
30
        if (!empty($this->client)) {
31
            $this->client->quit();
32
        }
33
    }
34
35
    /**
36
     * Connect clone.
37
     */
38
    final private function __clone()
39
    {
40
    }
41
}
42