ServerStats   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 64
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getStartTime() 0 4 1
A getConnections() 0 4 1
A getAcceptedConnections() 0 4 1
A getClosedConnections() 0 4 1
A getReceivedRequests() 0 4 1
1
<?php declare(strict_types=1);
2
3
namespace Igni\Network\Server;
4
5
/**
6
 * Value class that aggregates server's statistics.
7
 *
8
 * @package Igni\Network\Server
9
 */
10
class ServerStats
11
{
12
    private $stats;
13
14
    /**
15
     * ServerStats constructor.
16
     *
17
     * @param array $stats
18
     */
19 2
    public function __construct(array $stats)
20
    {
21 2
        $this->stats = $stats;
22 2
    }
23
24
    /**
25
     * Returns the timestamp of server since start
26
     *
27
     * @return int
28
     */
29 1
    public function getStartTime(): int
30
    {
31 1
        return $this->stats['start_time'];
32
    }
33
34
    /**
35
     * Returns the number of current connections
36
     *
37
     * @return int
38
     */
39 1
    public function getConnections(): int
40
    {
41 1
        return $this->stats['connection_num'];
42
    }
43
44
    /**
45
     * Returns the number of accepted connections
46
     *
47
     * @return int
48
     */
49 1
    public function getAcceptedConnections(): int
50
    {
51 1
        return $this->stats['accept_count'];
52
    }
53
54
    /**
55
     * Returns the number of closed connections
56
     *
57
     * @return int
58
     */
59 1
    public function getClosedConnections(): int
60
    {
61 1
        return $this->stats['close_count'];
62
    }
63
64
    /**
65
     * Returns the number of received requests
66
     *
67
     * @return int
68
     */
69 1
    public function getReceivedRequests(): int
70
    {
71 1
        return $this->stats['request_count'];
72
    }
73
}
74