Query   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 26
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMaxAnswerLength() 0 3 1
A getData() 0 6 1
A setExpectedAnswerSize() 0 4 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