Completed
Push — master ( 390e4e...b0ec12 )
by Taosikai
12:57
created

ReviewPublicConnection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 3
dl 0
loc 23
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 9 3
A getInterval() 0 4 1
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Server\TunnelServer\Timer;
7
8
class ReviewPublicConnection extends PeriodicTimer
9
{
10
    /**
11
     * {@inheritdoc}
12
     */
13
    public function __invoke()
14
    {
15
        foreach ($this->tunnelServer->getPublicConnections() as $key => $publicConnection) {
16
            if ($publicConnection->getWaitingDuration() > 120) {
17
                $this->tunnelServer->closePublicConnection($publicConnection, 'Waiting for more than 60 seconds without responding');
18
                $this->tunnelServer->getPublicConnections()->remove($key);
19
            }
20
        }
21
    }
22
23
    /**
24
     * {@inheritdoc}
25
     */
26
    public function getInterval()
27
    {
28
        return  60 * 1;
29
    }
30
}