Install   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 35
ccs 14
cts 14
cp 1
rs 10
c 0
b 0
f 0
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getCommand() 0 3 1
A getFilePosition() 0 3 1
A getExtraData() 0 3 2
A setFilePath() 0 4 1
A getData() 0 3 1
A setTimestamp() 0 4 1
1
<?php
2
3
namespace kalanis\RemoteRequest\Protocols\Fsp\Query;
4
5
6
use kalanis\RemoteRequest\Protocols\Fsp;
7
8
9
/**
10
 * Class Install
11
 * @package kalanis\RemoteRequest\Protocols\Fsp\Query
12
 * Install file
13
 * Start file upload - this one will be saved
14
 * To stop just send Install with zero length
15
 *
16
 * Correct name for v3 should be Publish - it publish uploaded file (move it from temp to target)
17
 */
18
class Install extends AQuery
19
{
20
    protected string $filePath = '';
21
    protected int $timestamp = 0;
22
23 1
    protected function getCommand(): int
24
    {
25 1
        return Fsp::CC_INSTALL;
26
    }
27
28 2
    public function setFilePath(string $filePath): self
29
    {
30 2
        $this->filePath = $filePath;
31 2
        return $this;
32
    }
33
34 2
    public function setTimestamp(int $timestamp): self
35
    {
36 2
        $this->timestamp = $timestamp;
37 2
        return $this;
38
    }
39
40 2
    protected function getFilePosition(): int
41
    {
42 2
        return strlen($this->getExtraData());
43
    }
44
45 2
    protected function getData(): string
46
    {
47 2
        return $this->filePath . chr(0);
48
    }
49
50 2
    protected function getExtraData(): string
51
    {
52 2
        return !empty($this->timestamp) ? Fsp\Strings::filler($this->timestamp, 4) : '' ;
53
    }
54
}
55