Router::leaved()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Service router command (from watcher)
4
 * User: moyo
5
 * Date: 25/09/2017
6
 * Time: 10:30 AM
7
 */
8
9
namespace Carno\Consul\Types;
10
11
use Carno\Net\Endpoint;
12
13
class Router
14
{
15
    public const JOIN = 0xC1;
16
    public const LEAVE = 0xC2;
17
18
    /**
19
     * @var int
20
     */
21
    private $cmd = null;
22
23
    /**
24
     * @var Endpoint
25
     */
26
    private $endpoint = null;
27
28
    /**
29
     * Router constructor.
30
     * @param int $cmd
31
     * @param Endpoint $endpoint
32
     */
33
    public function __construct(int $cmd, Endpoint $endpoint)
34
    {
35
        $this->cmd = $cmd;
36
        $this->endpoint = $endpoint;
37
    }
38
39
    /**
40
     * @return bool
41
     */
42
    public function joined() : bool
43
    {
44
        return $this->cmd === self::JOIN;
45
    }
46
47
    /**
48
     * @return bool
49
     */
50
    public function leaved() : bool
51
    {
52
        return $this->cmd === self::LEAVE;
53
    }
54
55
    /**
56
     * @return Endpoint
57
     */
58
    public function target() : Endpoint
59
    {
60
        return $this->endpoint;
61
    }
62
}
63