Passed
Pull Request — master (#30)
by Alexander
02:06
created

MemcachedServer::getWeight()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
namespace Yiisoft\CacheOld;
3
4
/**
5
 * MemcachedServer represents the configuration data for a single memcached server.
6
 *
7
 * See [PHP manual](http://php.net/manual/en/memcached.addserver.php) for detailed explanation
8
 * of each configuration property.
9
 */
10
final class MemcachedServer
11
{
12
    /**
13
     * @var string memcached server hostname or IP address
14
     */
15
    private $host;
16
17
    /**
18
     * @var int memcached server port
19
     */
20
    private $port;
21
22
    /**
23
     * @var int probability of using this server among all servers
24
     */
25
    private $weight;
26
27
    /**
28
     * @param string $host memcached server hostname or IP address
29
     * @param int $port memcached server port
30
     * @param int $weight probability of using this server among all servers
31
     */
32
    public function __construct(string $host, int $port = 11211, int $weight = 1)
33
    {
34
        $this->host = $host;
35
        $this->port = $port;
36
        $this->weight = $weight;
37
    }
38
39
    /**
40
     * @return string memcached server hostname or IP address
41
     */
42
    public function getHost(): string
43
    {
44
        return $this->host;
45
    }
46
47
    /**
48
     * @return int memcached server port
49
     */
50
    public function getPort(): int
51
    {
52
        return $this->port;
53
    }
54
55
    /**
56
     * @return int probability of using this server among all servers
57
     */
58
    public function getWeight(): int
59
    {
60
        return $this->weight;
61
    }
62
}
63