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

UidCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 39
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A toStream() 0 10 1
A getTag() 0 4 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
}