Server::createConnection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 7
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
crap 2
1
<?php
2
3
namespace SamIT\React\Smtp;
4
5
use Evenement\EventEmitter;
6
use React\EventLoop\LoopInterface;
7
use React\Http\ServerInterface;
8
use React\Socket\ServerInterface as SocketServerInterface;
9
use React\Socket\ConnectionInterface;
10
11
/** @event request */
12
class Server extends \React\Socket\Server
13
{
14
    public $recipientLimit = 100;
15
    public $bannerDelay = 0;
16
17
    private $loop;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
18 2
    public function __construct(LoopInterface $loop)
19
    {
20
        // We need to save $loop here since it is private for some reason.
21 2
        $this->loop = $loop;
22 2
        parent::__construct($loop);
23 2
    }
24
25
    public function createConnection($socket)
26
    {
27
        $conn = new Connection($socket, $this->loop);
28
        $conn->recipientLimit = $this->recipientLimit;
29
        $conn->bannerDelay = $this->bannerDelay;
30
        // We let messages "bubble up" from the connection to the server.
31
        $conn->on('message', function() {
32
            $this->emit('message', func_get_args());
33
        });
34
        return $conn;
35
    }
36
}
37