Body   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 38.46%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 8
c 3
b 0
f 0
dl 0
loc 33
ccs 5
cts 13
cp 0.3846
rs 10
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A asStream() 0 3 1
A isTextBody() 0 3 1
A equals() 0 3 1
A createEmpty() 0 3 1
A asString() 0 3 1
1
<?php
2
/**
3
 * This file is part of Phiremock.
4
 *
5
 * Phiremock is free software: you can redistribute it and/or modify
6
 * it under the terms of the GNU Lesser General Public License as published by
7
 * the Free Software Foundation, either version 3 of the License, or
8
 * (at your option) any later version.
9
 *
10
 * Phiremock is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with Phiremock.  If not, see <http://www.gnu.org/licenses/>.
17
 */
18
19
namespace Mcustiel\Phiremock\Domain\Http;
20
21
use Mcustiel\Phiremock\Common\StringStream;
22
use Psr\Http\Message\StreamInterface;
23
24
class Body
25
{
26
    /** @var string * */
27
    private $body;
28
29 6
    public function __construct(string $body)
30
    {
31 6
        $this->body = $body;
32 6
    }
33
34
    public function isTextBody(): bool
35
    {
36
        return true;
37
    }
38
39
    public static function createEmpty(): self
40
    {
41
        return new self('');
42
    }
43
44 6
    public function asString(): string
45
    {
46 6
        return $this->body;
47
    }
48
49
    public function asStream(): StreamInterface
50
    {
51
        return new StringStream($this->body);
52
    }
53
54
    public function equals(self $other): bool
55
    {
56
        return $this->asString() === $other->asString();
57
    }
58
}
59