Answer::setResponse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 1
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