Completed
Push — master ( 0f7687...6db947 )
by Arthur
01:19
created

ServerConfig::getAllowSelfSigned()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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 $clientsPerFork = WebSocketServerContract::CLIENTS_PER_FORK;
13
14
    /**
15
     * @var int
16
     */
17
    private $streamSelectTimeout = WebSocketServerContract::STREAM_SELECT_TIMEOUT;
18
19
    /**
20
     * @var string
21
     */
22
    private $host = WebSocketServerContract::DEFAULT_HOST;
23
24
    /**
25
     * @var int
26
     */
27
    private $port = WebSocketServerContract::DEFAULT_PORT;
28
29
    /**
30
     * @var bool
31
     */
32
    private $isForking = true;
33
34
    /**
35
     * @var string
36
     */
37
    private $processName = WebSocketServerContract::PROC_TITLE;
38
39
    /**
40
     * @var bool
41
     */
42
    private $checkOrigin = false;
43
44
    /**
45
     * @var array
46
     */
47
    private $origins = [];
48
49
50
    /**
51
     * @var bool
52
     */
53
    private $originHeader = false;
54
55
    /**
56
     * @var bool
57
     */
58
    private $isSsl = false;
59
60
    /**
61
     * @var string
62
     */
63
    private $localCert;
64
65
    /**
66
     * @var string
67
     */
68
    private $localPk;
69
70
    /**
71
     * @var bool
72
     */
73
    private $allowSelfSigned;
74
75
    /**
76
     * @var int
77
     */
78
    private $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
     */
163
    public function setForking(bool $isForking): ServerConfig
164
    {
165
        $this->isForking = $isForking;
166
        return $this;
167
    }
168
169
    /**
170
     * @return string
171
     */
172
    public function getProcessName(): string
173
    {
174
        return $this->processName;
175
    }
176
177
    /**
178
     * @param string $processName
179
     */
180
    public function setProcessName(string $processName): ServerConfig
181
    {
182
        $this->processName = $processName;
183
        return $this;
184
    }
185
186
    /**
187
     * @return bool
188
     */
189
    public function isCheckOrigin(): bool
190
    {
191
        return $this->checkOrigin;
192
    }
193
194
    /**
195
     * @param bool $checkOrigin
196
     * @return ServerConfig
197
     */
198
    public function setCheckOrigin(bool $checkOrigin): ServerConfig
199
    {
200
        $this->checkOrigin = $checkOrigin;
201
        return $this;
202
    }
203
204
    /**
205
     * @return array
206
     */
207
    public function getOrigins(): array
208
    {
209
        return $this->origins;
210
    }
211
212
    /**
213
     * @param array $origins
214
     * @return ServerConfig
215
     */
216
    public function setOrigins(array $origins): ServerConfig
217
    {
218
        if (empty($origins) === false) {
219
            $this->setCheckOrigin(true);
220
        }
221
        $this->origins = $origins;
222
        return $this;
223
    }
224
225
    /**
226
     * @return bool
227
     */
228
    public function isOriginHeader(): bool
229
    {
230
        return $this->originHeader;
231
    }
232
233
    /**
234
     * @param bool $originHeader
235
     * @return ServerConfig
236
     */
237
    public function setOriginHeader(bool $originHeader): ServerConfig
238
    {
239
        $this->originHeader = $originHeader;
240
        return $this;
241
    }
242
243
    /**
244
     * @param bool $isSsl
245
     * @return ServerConfig
246
     */
247
    public function setIsSsl(bool $isSsl): ServerConfig
248
    {
249
        $this->isSsl = $isSsl;
250
        return $this;
251
    }
252
253
    /**
254
     * @return bool
255
     */
256
    public function isSsl(): bool
257
    {
258
        return $this->isSsl;
259
    }
260
261
    /**
262
     * @param mixed $localCert
263
     * @return ServerConfig
264
     */
265
    public function setLocalCert(string $localCert): ServerConfig
266
    {
267
        $this->localCert = $localCert;
268
        return $this;
269
    }
270
271
    /**
272
     * @return mixed
273
     */
274
    public function getLocalCert(): string
275
    {
276
        return $this->localCert;
277
    }
278
279
    /**
280
     * @param mixed $localPk
281
     * @return ServerConfig
282
     */
283
    public function setLocalPk(string $localPk): ServerConfig
284
    {
285
        $this->localPk = $localPk;
286
        return $this;
287
    }
288
289
    /**
290
     * @return mixed
291
     */
292
    public function getLocalPk(): string
293
    {
294
        return $this->localPk;
295
    }
296
297
    /**
298
     * @param bool $allowSelfSigned
299
     * @return ServerConfig
300
     */
301
    public function setAllowSelfSigned(bool $allowSelfSigned): ServerConfig
302
    {
303
        $this->allowSelfSigned = $allowSelfSigned;
304
        return $this;
305
    }
306
307
    /**
308
     * @return bool
309
     */
310
    public function getAllowSelfSigned(): bool
311
    {
312
        return $this->allowSelfSigned;
313
    }
314
315
    /**
316
     * @param int $cryptoType
317
     * @return ServerConfig
318
     */
319
    public function setCryptoType(int $cryptoType): ServerConfig
320
    {
321
        $this->cryptoType = $cryptoType;
322
        return $this;
323
    }
324
325
    /**
326
     * @return mixed
327
     */
328
    public function getCryptoType(): int
329
    {
330
        return $this->cryptoType;
331
    }
332
}