Install::getData()   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\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