Service.php
926 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace AukeySwrpc\Register;
/**
* 注册中心服务
* Class Service
*
* @package AukeySwrpc\Register
* @author pengjch 2024311 10:25:46
*/
class Service
{
protected $host;
protected $port;
protected $weight;
public function __construct($host, $port, $weight)
{
$this->host = $host;
$this->port = $port;
$this->weight = $weight;
}
public static function build($host, $port, $weight)
{
return new static($host, $port, $weight);
}
public function getHost()
{
return $this->host;
}
public function getPort()
{
return $this->port;
}
public function getWeight()
{
return $this->weight;
}
public function toArray(): array
{
return [
'host' => $this->host,
'port' => $this->port,
'weight' => $this->weight
];
}
}