@@ -26,6 +26,9 @@ discard block |
||
26 | 26 | /** @var string */ |
27 | 27 | private $tempDir; |
28 | 28 | |
29 | + /** |
|
30 | + * @param string $tempDir |
|
31 | + */ |
|
29 | 32 | public function __construct($tempDir) |
30 | 33 | { |
31 | 34 | $this->tempDir = $tempDir; |
@@ -93,8 +96,7 @@ discard block |
||
93 | 96 | |
94 | 97 | /** |
95 | 98 | * @param $token |
96 | - * @param $fallback |
|
97 | - * @param string $action |
|
99 | + * @param \Closure $fallback |
|
98 | 100 | * @return ResponseInterface |
99 | 101 | * @throws Fio\QueueLimitException |
100 | 102 | * @throws Fio\ServiceUnavailableException |
@@ -152,6 +154,9 @@ discard block |
||
152 | 154 | } |
153 | 155 | } |
154 | 156 | |
157 | + /** |
|
158 | + * @param string $filename |
|
159 | + */ |
|
155 | 160 | private static function sleep($filename) |
156 | 161 | { |
157 | 162 | $criticalTime = time() - filemtime($filename); |
@@ -174,6 +179,9 @@ discard block |
||
174 | 179 | return self::$tokens[$key]; |
175 | 180 | } |
176 | 181 | |
182 | + /** |
|
183 | + * @param string $filename |
|
184 | + */ |
|
177 | 185 | private static function safeProtocol($filename) |
178 | 186 | { |
179 | 187 | return Utils\SafeStream::PROTOCOL . '://' . $filename; |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function download($token, $url) |
68 | 68 | { |
69 | - $response = $this->request($token, function (GuzzleHttp\Client $client) use ($url) { |
|
69 | + $response = $this->request($token, function(GuzzleHttp\Client $client) use ($url) { |
|
70 | 70 | return $client->request('GET', $url, $this->downloadOptions); |
71 | 71 | }); |
72 | 72 | self::detectDownloadResponse($response); |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | } |
86 | 86 | $newPost[] = ['name' => 'file', 'contents' => fopen($filename, 'r')]; |
87 | 87 | |
88 | - $response = $this->request($token, function (GuzzleHttp\Client $client) use ($url, $newPost) { |
|
88 | + $response = $this->request($token, function(GuzzleHttp\Client $client) use ($url, $newPost) { |
|
89 | 89 | return $client->request('POST', $url, [GuzzleHttp\RequestOptions::MULTIPART => $newPost]); |
90 | 90 | }); |
91 | 91 | return self::createXmlResponse($response->getBody()); |
@@ -116,12 +116,12 @@ discard block |
||
116 | 116 | throw $e; |
117 | 117 | } elseif ($i >= $this->limitLoop) { |
118 | 118 | fclose($file); |
119 | - throw new Fio\QueueLimitException('You have limit up requests to server ' . $this->limitLoop); |
|
119 | + throw new Fio\QueueLimitException('You have limit up requests to server '.$this->limitLoop); |
|
120 | 120 | } |
121 | 121 | self::sleep($tempFile); |
122 | 122 | $next = true; |
123 | 123 | } catch (GuzzleHttp\Exception\ServerException $e) { |
124 | - if($e->hasResponse()) { |
|
124 | + if ($e->hasResponse()) { |
|
125 | 125 | self::detectDownloadResponse($e->getResponse()); |
126 | 126 | } |
127 | 127 | throw self::createServiceUnavailableException(); |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | { |
169 | 169 | $key = substr($token, 10, -10); |
170 | 170 | if (!isset(self::$tokens[$key])) { |
171 | - self::$tokens[$key] = $this->tempDir . DIRECTORY_SEPARATOR . md5($key); |
|
171 | + self::$tokens[$key] = $this->tempDir.DIRECTORY_SEPARATOR.md5($key); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return self::$tokens[$key]; |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | |
177 | 177 | private static function safeProtocol($filename) |
178 | 178 | { |
179 | - return Utils\SafeStream::PROTOCOL . '://' . $filename; |
|
179 | + return Utils\SafeStream::PROTOCOL.'://'.$filename; |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | /** |