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

CommandContinuationRequestResponse::getBody()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Genkgo\Mail\Protocol\Imap\Response;
5
6
use Genkgo\Mail\Exception\AssertionFailedException;
7
use Genkgo\Mail\Protocol\Imap\ResponseInterface;
8
9
final class CommandContinuationRequestResponse implements ResponseInterface
10
{
11
    /**
12
     * @var string
13
     */
14
    private $line;
15
16
    /**
17
     * CommandContinuationRequestResponse constructor.
18
     * @param string $line
19
     */
20
    public function __construct(string $line)
21
    {
22
        $this->line = $line;
23
    }
24
25
    /**
26
     * @return string
27
     */
28
    public function __toString(): string
29
    {
30
        return trim('+' . $this->line);
31
    }
32
33
    /**
34
     * @param string $data
35
     * @return ResponseInterface
36
     */
37
    public function withBody(string $data): ResponseInterface
38
    {
39
        $clone = clone $this;
40
        $clone->line .= $data;
41
        return $clone;
42
    }
43
44
    /**
45
     * @param CompletionResult $expectedResult
46
     * @return ResponseInterface
47
     * @throws AssertionFailedException
48
     */
49
    public function assertCompletion(CompletionResult $expectedResult): ResponseInterface
50
    {
51
        throw new AssertionFailedException();
52
    }
53
54
    /**
55
     * @return ResponseInterface
56
     */
57
    public function assertContinuation(): ResponseInterface
58
    {
59
        return $this;
60
    }
61
62
    /**
63
     * @return ResponseInterface
64
     * @throws AssertionFailedException
65
     */
66
    public function assertTagged(): ResponseInterface
67
    {
68
        throw new AssertionFailedException('A command continuous request is never tagged');
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public function getBody(): string
75
    {
76
        return $this->line;
77
    }
78
}