UnsubscribeCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

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

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\MailboxName;
7
use Genkgo\Mail\Protocol\Imap\Tag;
8
use Genkgo\Mail\Stream\StringStream;
9
use Genkgo\Mail\StreamInterface;
10
11
final class UnsubscribeCommand extends AbstractCommand
12
{
13
    /**
14
     * @var Tag
15
     */
16
    private $tag;
17
18
    /**
19
     * @var MailboxName
20
     */
21
    private $mailbox;
22
23
    /**
24
     * @param Tag $tag
25
     * @param MailboxName $mailbox
26
     */
27 1
    public function __construct(Tag $tag, MailboxName $mailbox)
28
    {
29 1
        $this->tag = $tag;
30 1
        $this->mailbox = $mailbox;
31 1
    }
32
33
    /**
34
     * @return StreamInterface
35
     */
36 1
    protected function createStream(): StreamInterface
37
    {
38 1
        return new StringStream(
39 1
            \sprintf(
40 1
                'UNSUBSCRIBE %s',
41 1
                (string)$this->mailbox
42
            )
43
        );
44
    }
45
46
    /**
47
     * @return Tag
48
     */
49 1
    public function getTag(): Tag
50
    {
51 1
        return $this->tag;
52
    }
53
}
54