| Total Complexity | 7 |
| Total Lines | 72 |
| Duplicated Lines | 0 % |
| Coverage | 20% |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 10 | class ServerStats |
||
| 11 | { |
||
| 12 | private $stats; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * ServerStats 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 the timestamp of server since start |
||
| 26 | * |
||
| 27 | * @return int |
||
| 28 | */ |
||
| 29 | public function getStartTime(): int |
||
| 30 | { |
||
| 31 | return $this->stats['start_time']; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** |
||
| 35 | * Returns the number of current connections |
||
| 36 | * |
||
| 37 | * @return int |
||
| 38 | */ |
||
| 39 | public function getConnections(): int |
||
| 40 | { |
||
| 41 | return $this->stats['connection_num']; |
||
| 42 | } |
||
| 43 | |||
| 44 | /** |
||
| 45 | * Returns the number of accepted connections |
||
| 46 | * |
||
| 47 | * @return int |
||
| 48 | */ |
||
| 49 | public function getAcceptedConnections(): int |
||
| 50 | { |
||
| 51 | return $this->stats['accept_count']; |
||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Returns the number of closed connections |
||
| 56 | * |
||
| 57 | * @return int |
||
| 58 | */ |
||
| 59 | public function getClosedConnections(): int |
||
| 60 | { |
||
| 61 | return $this->stats['close_count']; |
||
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
| 65 | * Returns the number of queuing up tasks |
||
| 66 | * |
||
| 67 | * @return int |
||
| 68 | */ |
||
| 69 | public function getAwaitingConnections(): int |
||
| 70 | { |
||
| 71 | return $this->stats['close_count']; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Returns the number of received requests |
||
| 76 | * |
||
| 77 | * @return int |
||
| 78 | */ |
||
| 79 | public function getReceivedRequests(): int |
||
| 82 | } |
||
| 83 | } |
||
| 84 |