Answer::getContent()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 5
nc 4
nop 0
dl 0
loc 8
ccs 7
cts 7
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace kalanis\RemoteRequest\Protocols\Dummy;
4
5
6
/**
7
 * Class Answer
8
 * @package kalanis\RemoteRequest\Protocols\Dummy
9
 * Process server's answer - raw edition
10
 */
11
class Answer
12
{
13
    /** @var resource|string|null */
14
    protected $body = null;
15
16
    /**
17
     * @param resource|string|null $message
18
     * @return $this
19
     */
20 19
    public function setResponse($message): self
21
    {
22 19
        $this->body = $message;
23 19
        return $this;
24
    }
25
26 12
    public function getContent(): string
27
    {
28 12
        return is_null($this->body)
29 4
            ? ''
30 12
            : (
31 9
                is_resource($this->body)
32 9
                ? strval(stream_get_contents($this->body, -1, 0))
33 12
                : strval($this->body)
34 12
            )
35 12
        ;
36
    }
37
}
38