AQuery   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 56
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
wmc 7

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilePosition() 0 3 1
A getExtraData() 0 3 1
A compile() 0 10 1
A setKey() 0 4 1
A setSequence() 0 4 1
A __construct() 0 3 1
A getData() 0 3 1
1
<?php
2
3
namespace kalanis\RemoteRequest\Protocols\Fsp\Query;
4
5
6
use kalanis\RemoteRequest\Protocols\Fsp;
7
8
9
/**
10
 * Class AQuery
11
 * @package kalanis\RemoteRequest\Protocols\Fsp\Query
12
 * Abstract processor - common calls across the answer
13
 */
14
abstract class AQuery
15
{
16
    protected Fsp\Query $query;
17
    protected int $serverKey = 0;
18
    protected int $localSequence = 0;
19
20 15
    public function __construct(Fsp\Query $query)
21
    {
22 15
        $this->query = $query;
23
    }
24
25 15
    public function setKey(int $key = 0): self
26
    {
27 15
        $this->serverKey = $key;
28 15
        return $this;
29
    }
30
31 15
    public function setSequence(int $sequenceNumber = 0): self
32
    {
33 15
        $this->localSequence = $sequenceNumber;
34 15
        return $this;
35
    }
36
37 15
    public function compile(): string
38
    {
39 15
        return $this->query->body = $this->query
40 15
            ->setCommand($this->getCommand())
41 15
            ->setKey($this->serverKey)
42 15
            ->setSequence($this->localSequence)
43 15
            ->setFilePosition($this->getFilePosition())
44 15
            ->setContent($this->getData())
45 15
            ->setExtraData($this->getExtraData())
46 15
            ->getPacket()
47 15
        ;
48
    }
49
50
    /**
51
     * Commands as defined in \RemoteRequest\Protocols\Fsp::CC_*
52
     * @return int
53
     * @see \kalanis\RemoteRequest\Protocols\Fsp
54
     */
55
    abstract protected function getCommand(): int;
56
57 7
    protected function getFilePosition(): int
58
    {
59 7
        return 0;
60
    }
61
62 2
    protected function getData(): string
63
    {
64 2
        return '';
65
    }
66
67 8
    protected function getExtraData(): string
68
    {
69 8
        return '';
70
    }
71
}
72