Completed
Push — master ( afc89b...10bad0 )
by Eugene
05:20
created

AtConnectionHandler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A __invoke() 0 10 2
1
<?php
2
3
/**
4
 * This file is part of the Tarantool Client package.
5
 *
6
 * (c) Eugene Leonovich <[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
declare(strict_types=1);
13
14
namespace Tarantool\Client\Tests\Integration\FakeServer\Handler;
15
16
class AtConnectionHandler implements Handler
17
{
18
    private $atConnectionNumber;
19
    private $handler;
20
    private $connectionCount = 0;
21
22
    public function __construct(int $atConnectionNumber, Handler $handler)
23
    {
24
        $this->atConnectionNumber = $atConnectionNumber;
25
        $this->handler = $handler;
26
    }
27
28
    public function __invoke($conn, string $sid) : ?bool
29
    {
30
        ++$this->connectionCount;
31
32
        if ($this->connectionCount === $this->atConnectionNumber) {
33
            return ($this->handler)($conn, $sid);
34
        }
35
36
        return null;
37
    }
38
}
39