Completed
Push — master ( 5b05fa...1d7f97 )
by Dawid
13s queued 10s
created

ClientStats::getConnectTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Igni\Http\Server;
4
5
/**
6
 * Value class for aggregating client statistics.
7
 *
8
 * @package Igni\Http\Server
9
 */
10
class ClientStats
11
{
12
    private $stats;
13
14
    /**
15
     * ClientStats constructor.
16
     *
17
     * @param array $stats
18
     */
19 1
    public function __construct(array $stats)
20
    {
21 1
        $this->stats = $stats;
22 1
    }
23
24
    /**
25
     * Returns port used by client to connect to the server.
26
     *
27
     * @return int
28
     */
29
    public function getPort(): int
30
    {
31
        return $this->stats['remote_port'];
32
    }
33
34
    /**
35
     * Returns client's ip.
36
     *
37
     * @return string
38
     */
39
    public function getIp(): string
40
    {
41
        return $this->stats['remote_ip'];
42
    }
43
44
    /**
45
     * Returns unix timestamp when connection happened.
46
     *
47
     * @return int
48
     */
49
    public function getConnectTime(): int
50
    {
51
        return $this->stats['connect_time'];
52
    }
53
}
54