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

TrimCrlfConnection   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 9
lcom 1
cbo 1
dl 0
loc 84
c 0
b 0
f 0
ccs 0
cts 36
cp 0
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addListener() 0 4 1
A connect() 0 4 1
A disconnect() 0 4 1
A send() 0 4 1
A receive() 0 4 1
A upgrade() 0 4 1
A timeout() 0 4 1
A getMetaData() 0 4 1
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
}