-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathTransfer.php
More file actions
60 lines (51 loc) · 1.31 KB
/
Transfer.php
File metadata and controls
60 lines (51 loc) · 1.31 KB
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
55
56
57
58
59
60
<?php
namespace SplitIO\ThinSdk\Config;
class Transfer
{
private /*string*/ $sockFN;
private /*string*/ $connType;
private /*int*/ $timeout;
private /*int*/ $bufferSize;
private function __construct(string $sockFN, string $connType, ?int $timeout, ?int $bufferSize)
{
$this->sockFN = $sockFN;
$this->connType = $connType;
$this->timeout = $timeout;
$this->bufferSize = $bufferSize;
}
public function sockFN(): string
{
return $this->sockFN;
}
public function connType(): string
{
return $this->connType;
}
public function timeout()/*: ?int */
{
return $this->timeout;
}
public function bufferSize()/*: ?int */
{
return $this->bufferSize;
}
public static function fromArray(array $config)
{
$d = self::default();
return new Transfer(
$config['address'] ?? $d->sockFN(),
$config['type'] ?? $d->connType(),
$config['timeout'] ?? $d->timeout(),
$config['bufferSize'] ?? $d->bufferSize(),
);
}
public static function default(): Transfer
{
return new Transfer(
'/var/run/splitd.sock',
'unix-seqpacket',
null,
null,
);
}
}