Completed
Pull Request — master (#42)
by Frederik
01:59
created

UidCommand::toStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
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\Protocol\Imap\Tag;
8
use Genkgo\Mail\Stream\StringStream;
9
use Genkgo\Mail\StreamInterface;
10
11
final class UidCommand implements RequestInterface
12
{
13
14
    /**
15
     * @var RequestInterface
16
     */
17
    private $request;
18
19
    /**
20
     * UidCommand constructor.
21
     * @param RequestInterface $request
22
     */
23 1
    public function __construct(RequestInterface $request)
24
    {
25 1
        $this->request = $request;
26 1
    }
27
28
    /**
29
     * @return StreamInterface
30
     */
31 1
    public function toStream(): StreamInterface
32
    {
33 1
        return new StringStream(
34 1
            sprintf(
35 1
                '%s UID %s',
36 1
                (string)$this->getTag(),
37 1
                $this->getTag()->extractBodyFromLine((string) $this->request->toStream())
38
            )
39
        );
40
    }
41
42
    /**
43
     * @return Tag
44
     */
45 1
    public function getTag(): Tag
46
    {
47 1
        return $this->request->getTag();
48
    }
49
}