InitResponse::setPassedInitData()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 6
dl 0
loc 16
ccs 8
cts 8
cp 1
crap 1
rs 10
1
<?php
2
3
namespace kalanis\UploadPerPartes\Responses;
4
5
6
use kalanis\UploadPerPartes\Uploader\Data;
7
8
/**
9
 * Class InitResponse
10
 * @package kalanis\UploadPerPartes\Responses
11
 * Responses from server to client
12
 */
13
class InitResponse extends BasicResponse
14
{
15
    public string $name = '';
16
    public int $totalParts = 0;
17
    public int $lastKnownPart = 0;
18
    public int $partSize = 0;
19
    public string $encoder = '';
20
    public string $check = '';
21
22 15
    public function setInitData(
23
        Data $data,
24
        string $encoder,
25
        string $check
26
    ): self
27
    {
28 15
        $this->name = $data->targetName;
29 15
        $this->totalParts = $data->partsCount;
30 15
        $this->lastKnownPart = $data->lastKnownPart;
31 15
        $this->partSize = $data->bytesPerPart;
32 15
        $this->encoder = $encoder;
33 15
        $this->check = $check;
34 15
        return $this;
35
    }
36
37 8
    public function setPassedInitData(
38
        string $targetName,
39
        int $partsCount,
40
        int $lastKnownPart,
41
        int $bytesPerPart,
42
        string $encoder,
43
        string $check
44
    ): self
45
    {
46 8
        $this->name = $targetName;
47 8
        $this->totalParts = $partsCount;
48 8
        $this->lastKnownPart = $lastKnownPart;
49 8
        $this->partSize = $bytesPerPart;
50 8
        $this->encoder = $encoder;
51 8
        $this->check = $check;
52 8
        return $this;
53
    }
54
}
55