DataLogConnection::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol;
5
6
use Psr\Log\LoggerInterface;
7
8
final class DataLogConnection implements ConnectionInterface
9
{
10
    /**
11
     * @var ConnectionInterface
12
     */
13
    private $decoratedConnection;
14
15
    /**
16
     * @var LoggerInterface
17
     */
18
    private $logger;
19
20
    /**
21
     * @param ConnectionInterface $decoratedConnection
22
     * @param LoggerInterface $logger
23
     */
24
    public function __construct(ConnectionInterface $decoratedConnection, LoggerInterface $logger)
25
    {
26
        $this->decoratedConnection = $decoratedConnection;
27
        $this->logger = $logger;
28
    }
29
30
    /**
31
     * @param string $name
32
     * @param \Closure $callback
33
     */
34
    public function addListener(string $name, \Closure $callback): void
35
    {
36
        $this->decoratedConnection->addListener($name, $callback);
37
    }
38
39
    /**
40
     * @return void
41
     */
42
    public function connect(): void
43
    {
44
        $this->decoratedConnection->connect();
45
    }
46
47
    /**
48
     * @return void
49
     */
50
    public function disconnect(): void
51
    {
52
        $this->decoratedConnection->disconnect();
53
    }
54
55
    /**
56
     * @param string $request
57
     * @return int
58
     */
59
    public function send(string $request): int
60
    {
61
        $this->logger->info('-> ' . $request);
62
        return $this->decoratedConnection->send($request);
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function receive(): string
69
    {
70
        $data = $this->decoratedConnection->receive();
71
        $this->logger->info('<- ' . $data);
72
        return $data;
73
    }
74
75
    /**
76
     * @param int $type
77
     */
78
    public function upgrade(int $type): void
79
    {
80
        $this->decoratedConnection->upgrade($type);
81
    }
82
83
    /**
84
     * @param float $timeout
85
     */
86
    public function timeout(float $timeout): void
87
    {
88
        $this->decoratedConnection->timeout($timeout);
89
    }
90
91
    /**
92
     * @param array<int, string> $keys
93
     * @return array<string, mixed>
0 ignored issues
show
Documentation introduced by
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
94
     */
95
    public function getMetaData(array $keys = []): array
96
    {
97
        return $this->decoratedConnection->getMetaData($keys);
98
    }
99
}
100