Passed
Push — master ( c65021...b58a23 )
by Murilo
02:50
created

Redis   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __destruct() 0 4 2
A getClient() 0 3 1
A __clone() 0 2 1
A __construct() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Source\Infra\Cache\Redis;
6
7
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...
8
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...
9
10
/**
11
 * Redis class...
12
 *
13
 * @version 0.1.0
14
 * @author Murilo Chianfa <github.com/MuriloChianfa>
15
 * @package Source\Infra\Cache\Redis\Redis
16
 */
17
final class Redis
18
{
19
    private $client;
20
21
    public function __construct()
22
    {
23
        Autoloader::register();
24
25
        $this->client = new Client([
26
            'scheme' => CONF_REDIS_SCHEME,
27
            'host'   => CONF_REDIS_HOST,
28
            'port'   => CONF_REDIS_PORT,
29
        ]);
30
    }
31
32
    public function getClient(): Client
33
    {
34
        return $this->client;
35
    }
36
37
    public function __destruct()
38
    {
39
        if (!empty($this->client)) {
40
            $this->client->quit();
41
        }
42
    }
43
44
    /**
45
     * Connect clone.
46
     */
47
    final private function __clone()
48
    {
49
    }
50
}
51