6
6
7
7
use InvalidArgumentException ;
8
8
9
- class Endpoint
9
+ final class Endpoint
10
10
{
11
- const DEFAULT_SERVICE_NAME = 'unknown ' ;
11
+ public const DEFAULT_SERVICE_NAME = 'unknown ' ;
12
12
13
13
/**
14
14
* Service name in lowercase, such as "memcache" or "zipkin-web"
15
15
* Conventionally, when the service name isn't known, service_name = "unknown".
16
- *
17
- * @var string
18
16
*/
19
- private $ serviceName ;
17
+ private string $ serviceName ;
20
18
21
19
/**
22
- * @var string|null host address packed into 4 bytes.
20
+ * Host address packed into 4 bytes.
23
21
*/
24
- private $ ipv4 ;
22
+ private ? string $ ipv4 ;
25
23
26
- /**
27
- * @var string|null
28
- */
29
- private $ ipv6 ;
24
+ private ?string $ ipv6 ;
30
25
31
- /**
32
- * @var int|null
33
- */
34
- private $ port ;
26
+ private ?int $ port ;
35
27
36
28
private function __construct (string $ serviceName , ?string $ ipv4 , ?string $ ipv6 , ?int $ port )
37
29
{
@@ -41,14 +33,6 @@ private function __construct(string $serviceName, ?string $ipv4, ?string $ipv6,
41
33
$ this ->port = $ port ;
42
34
}
43
35
44
- /**
45
- * @param string $serviceName
46
- * @param string|null $ipv4
47
- * @param string|null $ipv6
48
- * @param int|null $port
49
- * @return Endpoint
50
- * @throws \InvalidArgumentException
51
- */
52
36
public static function create (
53
37
string $ serviceName ,
54
38
?string $ ipv4 = null ,
@@ -78,9 +62,6 @@ public static function create(
78
62
return new self ($ serviceName , $ ipv4 , $ ipv6 , $ port );
79
63
}
80
64
81
- /**
82
- * @return Endpoint
83
- */
84
65
public static function createFromGlobals (): self
85
66
{
86
67
return new self (
@@ -91,50 +72,31 @@ public static function createFromGlobals(): self
91
72
);
92
73
}
93
74
94
- /**
95
- * @return Endpoint
96
- */
97
75
public static function createAsEmpty (): self
98
76
{
99
77
return new self ('' , null , null , null );
100
78
}
101
79
102
- /**
103
- * @return string
104
- */
105
80
public function getServiceName (): string
106
81
{
107
82
return $ this ->serviceName ;
108
83
}
109
84
110
- /**
111
- * @return string|null
112
- */
113
85
public function getIpv4 (): ?string
114
86
{
115
87
return $ this ->ipv4 ;
116
88
}
117
89
118
- /**
119
- * @return string|null
120
- */
121
90
public function getIpv6 (): ?string
122
91
{
123
92
return $ this ->ipv6 ;
124
93
}
125
94
126
- /**
127
- * @return int|null
128
- */
129
95
public function getPort (): ?int
130
96
{
131
97
return $ this ->port ;
132
98
}
133
99
134
- /**
135
- * @param string $serviceName
136
- * @return Endpoint
137
- */
138
100
public function withServiceName (string $ serviceName ): Endpoint
139
101
{
140
102
return new self ($ serviceName , $ this ->ipv4 , $ this ->ipv6 , $ this ->port );
0 commit comments