Passed
Push — v7 ( 8c8f4f...b7a561 )
by Georges
01:55
created

Config::getPredisClient()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Geolim4
5
 * Date: 12/02/2018
6
 * Time: 23:10
7
 */
8
9
namespace Phpfastcache\Drivers\Predis;
10
11
use Phpfastcache\Config\ConfigurationOption;
12
13
class Config extends ConfigurationOption
14
{
15
    /**
16
     * @var string
17
     */
18
    protected $host = '127.0.0.1';
19
20
    /**
21
     * @var int
22
     */
23
    protected $port = 6379;
24
25
    /**
26
     * @var string
27
     */
28
    protected $password = '';
29
30
    /**
31
     * @var int
32
     */
33
    protected $database = 0;
34
35
    /**
36
     * @var \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...
37
     */
38
    protected $predisClient;
39
40
    /**
41
     * @return string
42
     */
43
    public function getHost(): string
44
    {
45
        return $this->host;
46
    }
47
48
    /**
49
     * @param string $host
50
     * @return Config
51
     */
52
    public function setHost(string $host): self
53
    {
54
        $this->host = $host;
55
        return $this;
56
    }
57
58
    /**
59
     * @return int
60
     */
61
    public function getPort(): int
62
    {
63
        return $this->port;
64
    }
65
66
    /**
67
     * @param int $port
68
     * @return Config
69
     */
70
    public function setPort(int $port): self
71
    {
72
        $this->port = $port;
73
        return $this;
74
    }
75
76
    /**
77
     * @return null
78
     */
79
    public function getPassword()
80
    {
81
        return $this->password;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->password returns the type string which is incompatible with the documented return type null.
Loading history...
82
    }
83
84
    /**
85
     * @param null $password
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $password is correct as it would always require null to be passed?
Loading history...
86
     * @return self
87
     */
88
    public function setPassword(string $password): self
89
    {
90
        $this->password = $password;
91
        return $this;
92
    }
93
94
    /**
95
     * @return int
96
     */
97
    public function getDatabase(): int
98
    {
99
        return $this->database;
100
    }
101
102
    /**
103
     * @param int $database
104
     * @return Config
105
     */
106
    public function setDatabase(int $database): self
107
    {
108
        $this->database = $database;
109
        return $this;
110
    }
111
112
    /**
113
     * @return array
114
     */
115
    public function getPredisConfigArray(): array
116
    {
117
        return [
118
          'host' => $this->getHost(),
119
          'port' => $this->getPort(),
120
          'password' => $this->getPassword() ?: null,
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->getPassword() targeting Phpfastcache\Drivers\Predis\Config::getPassword() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
121
          'database' => $this->getDatabase(),
122
        ];
123
    }
124
125
    /**
126
     * @return \Predis\Client|null
127
     */
128
    public function getPredisClient()
129
    {
130
        return $this->predisClient;
131
    }
132
133
    /**
134
     * @param \Predis\Client $predisClient|null
135
     * @return Config
136
     */
137
    public function setPredisClient(\Predis\Client $predisClient = null): Config
138
    {
139
        $this->predisClient = $predisClient;
140
        return $this;
141
    }
142
}