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

RenameCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 50
ccs 0
cts 20
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createStream() 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\Tag;
7
use Genkgo\Mail\Stream\StringStream;
8
use Genkgo\Mail\StreamInterface;
9
10
/**
11
 * Class RenameCommand
12
 * @package Genkgo\Mail\Protocol\Imap\Request
13
 */
14
final class RenameCommand extends AbstractCommand
15
{
16
    /**
17
     * @var Tag
18
     */
19
    private $tag;
20
    /**
21
     * @var string
22
     */
23
    private $mailboxName;
24
    /**
25
     * @var string
26
     */
27
    private $newName;
28
29
    /**
30
     * FetchCommand constructor.
31
     * @param Tag $tag
32
     * @param string $mailboxName
33
     * @param string $newName
34
     */
35
    public function __construct(Tag $tag, string $mailboxName, string $newName)
36
    {
37
        $this->tag = $tag;
38
        $this->mailboxName = $mailboxName;
39
        $this->newName = $newName;
40
    }
41
42
    /**
43
     * @return StreamInterface
44
     */
45
    protected function createStream(): StreamInterface
46
    {
47
        return new StringStream(
48
            sprintf(
49
                'RENAME %s %s',
50
                $this->mailboxName,
51
                $this->newName
52
            )
53
        );
54
    }
55
56
    /**
57
     * @return Tag
58
     */
59
    public function getTag(): Tag
60
    {
61
        return $this->tag;
62
    }
63
}