Completed
Push — master ( d7f2fe...303bad )
by Taosikai
11:51
created

ClientScanTimer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 8 3
A getInterval() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the slince/spike package.
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Spike\Server\Timer;
13
14
use Spike\Server\Event\ClientTerminateEvent;
15
16
class ClientScanTimer extends ServerTimer
17
{
18
    /**
19
     * {@inheritdoc}
20
     */
21
    public function __invoke()
22
    {
23
        foreach ($this->server->getClients() as $client) {
24
            if (time() - $client->getActiveAt()->getTimestamp() > 60 * 5) {
25
                $this->server->stopClient($client, ClientTerminateEvent::CLOSED_BY_TIMER);
26
            }
27
        }
28
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33
    public function getInterval()
34
    {
35
        return 5 * 60;
36
    }
37
}