NullConnection::upgrade()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Smtp;
5
6
use Genkgo\Mail\Protocol\ConnectionInterface;
7
8
final class NullConnection implements ConnectionInterface
9
{
10
    /** @var string */
11
    private $receive = '';
12
13 1
    public function addListener(string $name, \Closure $callback): void
14
    {
15 1
    }
16
17 1
    public function connect(): void
18
    {
19 1
    }
20
21 1
    public function disconnect(): void
22
    {
23 1
    }
24
25 11
    public function send(string $request): int
26
    {
27 11
        $this->pushResponseToBuffer($request);
28
29 11
        return 0;
30
    }
31
32 11
    public function receive(): string
33
    {
34 11
        return $this->receive;
35
    }
36
37 1
    public function upgrade(int $type): void
38
    {
39 1
    }
40
41 1
    public function timeout(float $timeout): void
42
    {
43 1
    }
44
45
    /**
46
     * @param array<int, string> $keys
47
     * @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...
48
     */
49 1
    public function getMetaData(array $keys = []): array
50
    {
51 1
        return [];
52
    }
53
54 11
    private function pushResponseToBuffer(string $request): void
55
    {
56 11
        $command = \explode(' ', \strtoupper(\trim($request)));
57 11
        switch ($command[0]) {
58 11
            case 'AUTH':
59 10
            case 'HELO':
60 9
            case 'EHLO':
61 8
            case 'MAIL':
62 7
            case 'RCPT':
63 6
            case 'RSET':
64 5
            case 'NOOP':
65 4
            case '.':
66 7
                $this->receive = '250 Ok';
67 7
                break;
68 4
            case 'DATA':
69 1
                $this->receive = '354 End data with <CR><LF>.<CR><LF>';
70 1
                break;
71 3
            case 'QUIT':
72 1
                $this->receive = '221 Bye';
73 1
                break;
74 2
            case 'VRFY':
75 1
                $this->receive = '252 null@null';
76 1
                break;
77
            default:
78 1
                $this->receive = '';
79
        }
80 11
    }
81
}
82