Completed
Push — master ( fbb370...38e670 )
by Alexander
05:52
created

MemcachedServer::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 3
crap 1
1
<?php
2
namespace Yiisoft\Cache;
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 17
    public function __construct(string $host, int $port = 11211, int $weight = 1)
33
    {
34 17
        $this->host = $host;
35 17
        $this->port = $port;
36 17
        $this->weight = $weight;
37
    }
38
39
    /**
40
     * @return string memcached server hostname or IP address
41
     */
42 17
    public function getHost(): string
43
    {
44 17
        return $this->host;
45
    }
46
47
    /**
48
     * @return int memcached server port
49
     */
50 17
    public function getPort(): int
51
    {
52 17
        return $this->port;
53
    }
54
55
    /**
56
     * @return int probability of using this server among all servers
57
     */
58 17
    public function getWeight(): int
59
    {
60 17
        return $this->weight;
61
    }
62
}
63