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

SelectCommand   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
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 43
c 0
b 0
f 0
ccs 0
cts 18
cp 0
rs 10

3 Methods

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