Query::getMaxAnswerLength()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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