Completed
Pull Request — master (#17)
by Frederik
02:00
created

TrimCrlfConnection::addListener()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol;
5
6
final class TrimCrlfConnection implements ConnectionInterface
7
{
8
9
    /**
10
     * @var ConnectionInterface
11
     */
12
    private $decoratedConnection;
13
14
    /**
15
     * AppendCrlfConnection constructor.
16
     * @param ConnectionInterface $decoratedConnection
17
     */
18
    public function __construct(ConnectionInterface $decoratedConnection)
19
    {
20
        $this->decoratedConnection = $decoratedConnection;
21
    }
22
23
    /**
24
     * @param string $name
25
     * @param \Closure $callback
26
     */
27
    public function addListener(string $name, \Closure $callback): void
28
    {
29
        $this->decoratedConnection->addListener($name, $callback);
30
    }
31
32
    /**
33
     * @return void
34
     */
35
    public function connect(): void
36
    {
37
        $this->decoratedConnection->connect();
38
    }
39
40
    /**
41
     * @return void
42
     */
43
    public function disconnect(): void
44
    {
45
        $this->decoratedConnection->disconnect();
46
    }
47
48
    /**
49
     * @param string $request
50
     * @return int
51
     */
52
    public function send(string $request): int
53
    {
54
        return $this->decoratedConnection->send($request);
55
    }
56
57
    /**
58
     * @return string
59
     */
60
    public function receive(): string
61
    {
62
        return rtrim($this->decoratedConnection->receive(), "\r\n");
63
    }
64
65
    /**
66
     * @param int $type
67
     */
68
    public function upgrade(int $type): void
69
    {
70
        $this->decoratedConnection->upgrade($type);
71
    }
72
73
    /**
74
     * @param float $timeout
75
     */
76
    public function timeout(float $timeout): void
77
    {
78
        $this->decoratedConnection->timeout($timeout);
79
    }
80
81
    /**
82
     * @param array $keys
83
     * @return array
84
     */
85
    public function getMetaData(array $keys = []): array
86
    {
87
        return $this->decoratedConnection->getMetaData($keys);
88
    }
89
}