Completed
Push — master ( 4aafbf...33c9c4 )
by Georges
19s queued 11s
created

Config::getOptPrefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 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
     * @var string
42
     */
43
    protected $optPrefix = '';
44
45
    /**
46
     * @return string
47
     */
48
    public function getHost(): string
49
    {
50
        return $this->host;
51
    }
52
53
    /**
54
     * @param string $host
55
     * @return Config
56
     */
57
    public function setHost(string $host): self
58
    {
59
        $this->host = $host;
60
        return $this;
61
    }
62
63
    /**
64
     * @return int
65
     */
66
    public function getPort(): int
67
    {
68
        return $this->port;
69
    }
70
71
    /**
72
     * @param int $port
73
     * @return Config
74
     */
75
    public function setPort(int $port): self
76
    {
77
        $this->port = $port;
78
        return $this;
79
    }
80
81
    /**
82
     * @return null
83
     */
84
    public function getPassword()
85
    {
86
        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...
87
    }
88
89
    /**
90
     * @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...
91
     * @return self
92
     */
93
    public function setPassword(string $password): self
94
    {
95
        $this->password = $password;
96
        return $this;
97
    }
98
99
    /**
100
     * @return int
101
     */
102
    public function getDatabase(): int
103
    {
104
        return $this->database;
105
    }
106
107
    /**
108
     * @param int $database
109
     * @return Config
110
     */
111
    public function setDatabase(int $database): self
112
    {
113
        $this->database = $database;
114
        return $this;
115
    }
116
117
    /**
118
     * @return array
119
     */
120
    public function getPredisConfigArray(): array
121
    {
122
        return [
123
            'host' => $this->getHost(),
124
            'port' => $this->getPort(),
125
            '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...
126
            'database' => $this->getDatabase(),
127
        ];
128
    }
129
130
    /**
131
     * @return \Predis\Client|null
132
     */
133
    public function getPredisClient()
134
    {
135
        return $this->predisClient;
136
    }
137
138
    /**
139
     * @param \Predis\Client $predisClient |null
140
     * @return Config
141
     */
142
    public function setPredisClient(\Predis\Client $predisClient = null): Config
143
    {
144
        $this->predisClient = $predisClient;
145
        return $this;
146
    }
147
148
    /**
149
     * @return string
150
     * @since 7.0.2
151
     */
152
    public function getOptPrefix(): string
153
    {
154
        return $this->optPrefix;
155
    }
156
157
    /**
158
     * @param string $optPrefix
159
     * @return Config
160
     * @since 7.0.2
161
     */
162
    public function setOptPrefix(string $optPrefix): Config
163
    {
164
        $this->optPrefix = trim($optPrefix);
165
        return $this;
166
    }
167
}