Completed
Pull Request — master (#42)
by Frederik
03:52
created

AppendCommand::createStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\Request;
5
6
use Genkgo\Mail\Protocol\Imap\ParenthesizedList;
7
use Genkgo\Mail\Protocol\Imap\Tag;
8
use Genkgo\Mail\Stream\StringStream;
9
use Genkgo\Mail\StreamInterface;
10
11
/**
12
 * Class AppendCommand
13
 * @package Genkgo\Mail\Protocol\Imap\Request
14
 */
15
final class AppendCommand extends AbstractCommand
16
{
17
    /**
18
     * @var Tag
19
     */
20
    private $tag;
21
    /**
22
     * @var string
23
     */
24
    private $mailboxName;
25
    /**
26
     * @var ParenthesizedList
27
     */
28
    private $flags;
29
    /**
30
     * @var int
31
     */
32
    private $size;
33
34
    /**
35
     * FetchCommand constructor.
36
     * @param Tag $tag
37
     * @param string $mailboxName
38
     * @param ParenthesizedList $flags
39
     * @param int $size
40
     */
41
    public function __construct(Tag $tag, string $mailboxName, int $size, ParenthesizedList $flags)
42
    {
43
        $this->tag = $tag;
44
        $this->mailboxName = $mailboxName;
45
        $this->flags = $flags;
46
        $this->size = $size;
47
    }
48
49
    /**
50
     * @return StreamInterface
51
     */
52
    protected function createStream(): StreamInterface
53
    {
54
        return new StringStream(
55
            sprintf(
56
                'APPEND %s %s {%s}',
57
                $this->mailboxName,
58
                (string)$this->flags,
59
                (string)$this->size
60
            )
61
        );
62
    }
63
64
    /**
65
     * @return Tag
66
     */
67
    public function getTag(): Tag
68
    {
69
        return $this->tag;
70
    }
71
}