Completed
Push — master ( 9561ee...bb752b )
by Dawid
02:42
created

ClientStats   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 42
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getConnectTime() 0 3 1
A getPort() 0 3 1
A getIp() 0 3 1
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 5
    public function __construct(array $stats)
20
    {
21 5
        $this->stats = $stats;
22 5
    }
23
24
    /**
25
     * Returns port used by client to connect to the server.
26
     *
27
     * @return int
28
     */
29 1
    public function getPort(): int
30
    {
31 1
        return $this->stats['remote_port'];
32
    }
33
34
    /**
35
     * Returns client's ip.
36
     *
37
     * @return string
38
     */
39 1
    public function getIp(): string
40
    {
41 1
        return $this->stats['remote_ip'];
42
    }
43
44
    /**
45
     * Returns unix timestamp when connection happened.
46
     *
47
     * @return int
48
     */
49 1
    public function getConnectTime(): int
50
    {
51 1
        return $this->stats['connect_time'];
52
    }
53
}
54