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

ServerStats::getAwaitingConnections()   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 that aggregates server's statistics.
7
 *
8
 * @package Igni\Http\Server
9
 */
10
class ServerStats
11
{
12
    private $stats;
13
14
    /**
15
     * ServerStats constructor.
16
     *
17
     * @param array $stats
18
     */
19 3
    public function __construct(array $stats)
20
    {
21 3
        $this->stats = $stats;
22 3
    }
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