Query::setExpectedAnswerSize()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
crap 2
1
<?php
2
3
namespace kalanis\RemoteRequest\Protocols\Dummy;
4
5
6
use kalanis\RemoteRequest\Interfaces;
7
use kalanis\RemoteRequest\Protocols\Helper;
8
use kalanis\RemoteRequest\RequestException;
9
10
11
/**
12
 * Class Query
13
 * @package RemoteRequest\Protocols\Dummy
14
 * Simple query to remote source
15
 */
16
class Query implements Interfaces\IQuery
17
{
18
    public string $body = '';
19
    public ?int $maxLength = null;
20
21 1
    public function setExpectedAnswerSize(?int $maxLength = null): self
22
    {
23 1
        $this->maxLength = !is_null($maxLength) ? $maxLength : $this->maxLength;
24 1
        return $this;
25
    }
26
27 5
    public function getMaxAnswerLength(): ?int
28
    {
29 5
        return $this->maxLength;
30
    }
31
32
    /**
33
     * @throws RequestException
34
     * @return resource
35
     */
36 4
    public function getData()
37
    {
38 4
        $storage = Helper::getMemStorage();
39 4
        fwrite($storage, $this->body);
40 4
        rewind($storage);
41 4
        return $storage;
42
    }
43
}
44