Passed
Branch master (32af5e)
by Arthur
06:54
created

ServerConfig::getOrigins()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace WSSC\Components;
4
5
use WSSC\Contracts\WebSocketServerContract;
6
7
class ServerConfig
8
{
9
    /**
10
     * @var int
11
     */
12
    private int $clientsPerFork = WebSocketServerContract::CLIENTS_PER_FORK;
13
14
    /**
15
     * @var int
16
     */
17
    private int $streamSelectTimeout = WebSocketServerContract::STREAM_SELECT_TIMEOUT;
18
19
    /**
20
     * @var string
21
     */
22
    private string $host = WebSocketServerContract::DEFAULT_HOST;
23
24
    /**
25
     * @var int
26
     */
27
    private int $port = WebSocketServerContract::DEFAULT_PORT;
28
29
    /**
30
     * @var bool
31
     */
32
    private bool $isForking = true;
33
34
    /**
35
     * @var string
36
     */
37
    private string $processName = WebSocketServerContract::PROC_TITLE;
38
39
    /**
40
     * @var bool
41
     */
42
    private bool $checkOrigin = false;
43
44
    /**
45
     * @var array
46
     */
47
    private array $origins = [];
48
49
50
    /**
51
     * @var bool
52
     */
53
    private bool $originHeader = false;
54
55
    /**
56
     * @var bool
57
     */
58
    private bool $isSsl = false;
59
60
    /**
61
     * @var string
62
     */
63
    private string $localCert;
64
65
    /**
66
     * @var string
67
     */
68
    private string $localPk;
69
70
    /**
71
     * @var bool
72
     */
73
    private bool $allowSelfSigned;
74
75
    /**
76
     * @var int
77
     */
78
    private int $cryptoType;
79
80
    /**
81
     * @return mixed
82
     */
83
    public function getClientsPerFork(): int
84
    {
85
        return $this->clientsPerFork;
86
    }
87
88
    /**
89
     * @param mixed $clientsPerFork
90
     * @return ServerConfig
91
     */
92
    public function setClientsPerFork(int $clientsPerFork): ServerConfig
93
    {
94
        $this->clientsPerFork = $clientsPerFork;
95
        return $this;
96
    }
97
98
    /**
99
     * @return mixed
100
     */
101
    public function getStreamSelectTimeout(): int
102
    {
103
        return $this->streamSelectTimeout;
104
    }
105
106
    /**
107
     * @param mixed $streamSelectTimeout
108
     * @return ServerConfig
109
     */
110
    public function setStreamSelectTimeout(int $streamSelectTimeout): ServerConfig
111
    {
112
        $this->streamSelectTimeout = $streamSelectTimeout;
113
        return $this;
114
    }
115
116
    /**
117
     * @return string
118
     */
119
    public function getHost(): string
120
    {
121
        return $this->host;
122
    }
123
124
    /**
125
     * @param string $host
126
     * @return ServerConfig
127
     */
128
    public function setHost(string $host): ServerConfig
129
    {
130
        $this->host = $host;
131
        return $this;
132
    }
133
134
    /**
135
     * @return int
136
     */
137
    public function getPort(): int
138
    {
139
        return $this->port;
140
    }
141
142
    /**
143
     * @param int $port
144
     * @return ServerConfig
145
     */
146
    public function setPort(int $port): ServerConfig
147
    {
148
        $this->port = $port;
149
        return $this;
150
    }
151
152
    /**
153
     * @return bool
154
     */
155
    public function isForking(): bool
156
    {
157
        return $this->isForking;
158
    }
159
160
    /**
161
     * @param bool $isForking
162
     * @return ServerConfig
163
     */
164
    public function setForking(bool $isForking): ServerConfig
165
    {
166
        $this->isForking = $isForking;
167
        return $this;
168
    }
169
170
    /**
171
     * @return string
172
     */
173
    public function getProcessName(): string
174
    {
175
        return $this->processName;
176
    }
177
178
    /**
179
     * @param string $processName
180
     */
181
    public function setProcessName(string $processName): ServerConfig
182
    {
183
        $this->processName = $processName;
184
        return $this;
185
    }
186
187
    /**
188
     * @return bool
189
     */
190
    public function isCheckOrigin(): bool
191
    {
192
        return $this->checkOrigin;
193
    }
194
195
    /**
196
     * @param bool $checkOrigin
197
     * @return ServerConfig
198
     */
199
    public function setCheckOrigin(bool $checkOrigin): ServerConfig
200
    {
201
        $this->checkOrigin = $checkOrigin;
202
        return $this;
203
    }
204
205
    /**
206
     * @return array
207
     */
208
    public function getOrigins(): array
209
    {
210
        return $this->origins;
211
    }
212
213
    /**
214
     * @param array $origins
215
     * @return ServerConfig
216
     */
217
    public function setOrigins(array $origins): ServerConfig
218
    {
219
        if (empty($origins) === false) {
220
            $this->setCheckOrigin(true);
221
        }
222
        $this->origins = $origins;
223
        return $this;
224
    }
225
226
    /**
227
     * @return bool
228
     */
229
    public function isOriginHeader(): bool
230
    {
231
        return $this->originHeader;
232
    }
233
234
    /**
235
     * @param bool $originHeader
236
     * @return ServerConfig
237
     */
238
    public function setOriginHeader(bool $originHeader): ServerConfig
239
    {
240
        $this->originHeader = $originHeader;
241
        return $this;
242
    }
243
244
    /**
245
     * @param bool $isSsl
246
     * @return ServerConfig
247
     */
248
    public function setIsSsl(bool $isSsl): ServerConfig
249
    {
250
        $this->isSsl = $isSsl;
251
        return $this;
252
    }
253
254
    /**
255
     * @return bool
256
     */
257
    public function isSsl(): bool
258
    {
259
        return $this->isSsl;
260
    }
261
262
    /**
263
     * @param mixed $localCert
264
     * @return ServerConfig
265
     */
266
    public function setLocalCert(string $localCert): ServerConfig
267
    {
268
        $this->localCert = $localCert;
269
        return $this;
270
    }
271
272
    /**
273
     * @return mixed
274
     */
275
    public function getLocalCert(): string
276
    {
277
        return $this->localCert;
278
    }
279
280
    /**
281
     * @param mixed $localPk
282
     * @return ServerConfig
283
     */
284
    public function setLocalPk(string $localPk): ServerConfig
285
    {
286
        $this->localPk = $localPk;
287
        return $this;
288
    }
289
290
    /**
291
     * @return mixed
292
     */
293
    public function getLocalPk(): string
294
    {
295
        return $this->localPk;
296
    }
297
298
    /**
299
     * @param bool $allowSelfSigned
300
     * @return ServerConfig
301
     */
302
    public function setAllowSelfSigned(bool $allowSelfSigned): ServerConfig
303
    {
304
        $this->allowSelfSigned = $allowSelfSigned;
305
        return $this;
306
    }
307
308
    /**
309
     * @return bool
310
     */
311
    public function getAllowSelfSigned(): bool
312
    {
313
        return $this->allowSelfSigned;
314
    }
315
316
    /**
317
     * @param int $cryptoType
318
     * @return ServerConfig
319
     */
320
    public function setCryptoType(int $cryptoType): ServerConfig
321
    {
322
        $this->cryptoType = $cryptoType;
323
        return $this;
324
    }
325
326
    /**
327
     * @return mixed
328
     */
329
    public function getCryptoType(): int
330
    {
331
        return $this->cryptoType;
332
    }
333
}