1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace kalanis\UploadPerPartes\Target\Remote; |
4
|
|
|
|
5
|
|
|
|
6
|
|
|
use kalanis\UploadPerPartes\Interfaces\IOperations; |
7
|
|
|
use kalanis\UploadPerPartes\Responses\BasicResponse; |
8
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class Internals |
12
|
|
|
* @package kalanis\UploadPerPartes\Target\Remote |
13
|
|
|
* Process responses from internal php functions |
14
|
|
|
*/ |
15
|
|
|
class Internals implements IOperations |
16
|
|
|
{ |
17
|
|
|
protected Internals\Client $client; |
18
|
|
|
protected Internals\Request $request; |
19
|
|
|
protected Internals\Response $response; |
20
|
|
|
|
21
|
7 |
|
public function __construct(Internals\Client $client, Internals\Request $request, Internals\Response $response) |
22
|
|
|
{ |
23
|
7 |
|
$this->client = $client; |
24
|
7 |
|
$this->request = $request; |
25
|
7 |
|
$this->response = $response; |
26
|
7 |
|
} |
27
|
|
|
|
28
|
1 |
|
public function init(string $targetPath, string $targetFileName, int $length, string $clientData = ''): BasicResponse |
29
|
|
|
{ |
30
|
1 |
|
return $this->response->init( |
31
|
1 |
|
$this->client->request( |
32
|
1 |
|
$this->request->init($targetPath, $targetFileName, $length) |
33
|
|
|
), |
34
|
|
|
$clientData |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
1 |
|
public function check(string $serverData, int $segment, string $method, string $clientData = ''): BasicResponse |
39
|
|
|
{ |
40
|
1 |
|
return $this->response->check( |
41
|
1 |
|
$this->client->request( |
42
|
1 |
|
$this->request->check($serverData, $segment, $method) |
43
|
|
|
), |
44
|
|
|
$clientData |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
1 |
|
public function truncate(string $serverData, int $segment, string $clientData = ''): BasicResponse |
49
|
|
|
{ |
50
|
1 |
|
return $this->response->truncate( |
51
|
1 |
|
$this->client->request( |
52
|
1 |
|
$this->request->truncate($serverData, $segment) |
53
|
|
|
), |
54
|
|
|
$clientData |
55
|
|
|
); |
56
|
|
|
} |
57
|
|
|
|
58
|
1 |
|
public function upload(string $serverData, string $content, string $method, string $clientData = ''): BasicResponse |
59
|
|
|
{ |
60
|
1 |
|
return $this->response->upload( |
61
|
1 |
|
$this->client->request( |
62
|
1 |
|
$this->request->upload($serverData, $content, $method) |
63
|
|
|
), |
64
|
|
|
$clientData |
65
|
|
|
); |
66
|
|
|
} |
67
|
|
|
|
68
|
1 |
|
public function done(string $serverData, string $clientData = ''): BasicResponse |
69
|
|
|
{ |
70
|
1 |
|
return $this->response->done( |
71
|
1 |
|
$this->client->request( |
72
|
1 |
|
$this->request->done($serverData) |
73
|
|
|
), |
74
|
|
|
$clientData |
75
|
|
|
); |
76
|
|
|
} |
77
|
|
|
|
78
|
1 |
|
public function cancel(string $serverData, string $clientData = ''): BasicResponse |
79
|
|
|
{ |
80
|
1 |
|
return $this->response->cancel( |
81
|
1 |
|
$this->client->request( |
82
|
1 |
|
$this->request->cancel($serverData) |
83
|
|
|
), |
84
|
|
|
$clientData |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|