-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathServer.php
92 lines (82 loc) · 1.56 KB
/
Server.php
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace shakura\yii2\gearman;
use Serializable;
class Server implements Serializable
{
/**
* @var string
*/
private $host = '127.0.0.1';
/**
* @var int
*/
private $port = 4730;
/**
* @param string|null $host
* @param int|null $port
*/
public function __construct($host = null, $port = null)
{
if (null !== $host) {
$this->setHost($host);
}
if (null !== $port) {
$this->setPort($port);
}
}
/**
* @return string
*/
public function getHost()
{
return $this->host;
}
/**
* @param string $host
* @return $this
*/
public function setHost($host)
{
$this->host = $host;
return $this;
}
/**
* @return int
*/
public function getPort()
{
return $this->port;
}
/**
* @param int $port
* @return $this
*/
public function setPort($port)
{
$this->port = $port;
return $this;
}
/**
* @return string
*/
public function serialize()
{
return serialize([
'host' => $this->getHost(),
'port' => $this->getPort(),
]);
}
/**
* @param string $serialized
*/
public function unserialize($serialized)
{
$data = unserialize($serialized);
if (isset($data['host'])) {
$this->setHost($data['host']);
}
if (isset($data['port'])) {
$this->setPort($data['port']);
}
}
}