AbstractCommand::toStream()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\Request;
5
6
use Genkgo\Mail\Protocol\Imap\RequestInterface;
7
use Genkgo\Mail\Stream\ConcatenatedStream;
8
use Genkgo\Mail\Stream\StringStream;
9
use Genkgo\Mail\StreamInterface;
10
11
abstract class AbstractCommand implements RequestInterface
12
{
13
    /**
14
     * @return StreamInterface
15
     */
16
    abstract protected function createStream(): StreamInterface;
17
18
    /**
19
     * @return StreamInterface
20
     */
21 50
    final public function toStream(): StreamInterface
22
    {
23 50
        return new ConcatenatedStream([
24 50
            new StringStream((string)$this->getTag() . ' '),
25 50
            $this->createStream()
26
        ]);
27
    }
28
}
29