Service   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 6
dl 0
loc 32
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A id() 0 3 1
A name() 0 3 1
1
<?php
2
/**
3
 * Type service
4
 * User: moyo
5
 * Date: 24/08/2017
6
 * Time: 4:08 PM
7
 */
8
9
namespace Carno\Consul\Types;
10
11
use Carno\Consul\Chips\SDeregister;
12
use Carno\Consul\Chips\SEndpoints;
13
use Carno\Consul\Chips\SRegister;
14
use Carno\Consul\Chips\SVersions;
15
use Carno\Consul\Contracts\Defaults;
16
17
class Service
18
{
19
    use SRegister, SDeregister, SEndpoints, SVersions;
20
21
    /**
22
     * @var string
23
     */
24
    private $name = null;
25
26
    /**
27
     * Service constructor.
28
     * @param string $name
29
     */
30
    public function __construct(string $name)
31
    {
32
        $this->name = $name;
33
    }
34
35
    /**
36
     * @return string
37
     */
38
    public function id() : string
39
    {
40
        return sprintf('%s:%s-%s', Defaults::SVC_FLAG, $this->name, $this->endpoint()->id());
41
    }
42
43
    /**
44
     * @return string
45
     */
46
    public function name() : string
47
    {
48
        return $this->name;
49
    }
50
}
51