InMemoryLocation::unserialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 5
cp 0
rs 9.4286
cc 1
eloc 4
nc 1
nop 1
crap 2
1
<?php
2
3
namespace AsyncPHP\Remit\Location;
4
5
use AsyncPHP\Remit\Location;
6
7
final class InMemoryLocation implements Location
8
{
9
    /**
10
     * @var string
11
     */
12
    private $host;
13
14
    /**
15
     * @var int
16
     */
17
    private $port;
18
19
    /**
20
     * @param string $host
21
     * @param int $port
22
     */
23
    public function __construct($host, $port)
24
    {
25
        $this->host = $host;
26
        $this->port = $port;
27
    }
28
29
    /**
30
     * @inheritdoc
31
     *
32
     * @return string
33
     */
34
    public function getHost()
35
    {
36
        return $this->host;
37
    }
38
39
    /**
40
     * @inheritdoc
41
     *
42
     * @return int
43
     */
44
    public function getPort()
45
    {
46
        return $this->port;
47
    }
48
49
    /**
50
     * @inheritdoc
51
     *
52
     * @return string
53
     */
54
    public function serialize()
55
    {
56
        return serialize([
57
            "host" => $this->host,
58
            "port" => $this->port,
59
        ]);
60
    }
61
62
    /**
63
     * @inheritdoc
64
     *
65
     * @param string $serialized
66
     */
67
    public function unserialize($serialized)
68
    {
69
        $unserialized = unserialize($serialized);
70
71
        $this->host = $unserialized["host"];
72
        $this->port = $unserialized["port"];
73
    }
74
}
75