Completed
Pull Request — master (#42)
by Frederik
02:26
created

ListCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 50
ccs 13
cts 13
cp 1
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\MailboxWildcard;
7
use Genkgo\Mail\Protocol\Imap\Tag;
8
use Genkgo\Mail\Stream\StringStream;
9
use Genkgo\Mail\StreamInterface;
10
11
/**
12
 * Class ListCommand
13
 * @package Genkgo\Mail\Protocol\Imap\Request
14
 */
15
final class ListCommand extends AbstractCommand
16
{
17
    /**
18
     * @var Tag
19
     */
20
    private $tag;
21
    /**
22
     * @var MailboxWildcard
23
     */
24
    private $mailbox;
25
    /**
26
     * @var MailboxWildcard
27
     */
28
    private $referenceName;
29
30
    /**
31
     * ListCommand constructor.
32
     * @param Tag $tag
33
     * @param MailboxWildcard $referenceName
34
     * @param MailboxWildcard $mailbox
35
     */
36 2
    public function __construct(Tag $tag, MailboxWildcard $referenceName , MailboxWildcard $mailbox)
37
    {
38 2
        $this->tag = $tag;
39 2
        $this->mailbox = $mailbox;
40 2
        $this->referenceName = $referenceName;
41 2
    }
42
43
    /**
44
     * @return StreamInterface
45
     */
46 2
    protected function createStream(): StreamInterface
47
    {
48 2
        return new StringStream(
49 2
            sprintf(
50 2
                'LIST %s %s',
51 2
                (string)$this->referenceName,
52 2
                (string)$this->mailbox
53
            )
54
        );
55
    }
56
57
    /**
58
     * @return Tag
59
     */
60 2
    public function getTag(): Tag
61
    {
62 2
        return $this->tag;
63
    }
64
}