@@ -2,10 +2,10 @@ |
||
2 | 2 | |
3 | 3 | namespace h4kuna\Fio\Request; |
4 | 4 | |
5 | -use GuzzleHttp, |
|
6 | - h4kuna\Fio, |
|
7 | - h4kuna\Fio\Response\Pay, |
|
8 | - Nette\Utils; |
|
5 | +use GuzzleHttp; |
|
6 | +use h4kuna\Fio; |
|
7 | +use h4kuna\Fio\Response\Pay; |
|
8 | +use Nette\Utils; |
|
9 | 9 | |
10 | 10 | class Queue implements IQueue |
11 | 11 | { |
@@ -25,6 +25,9 @@ discard block |
||
25 | 25 | /** @var string */ |
26 | 26 | private $tempDir; |
27 | 27 | |
28 | + /** |
|
29 | + * @param string $tempDir |
|
30 | + */ |
|
28 | 31 | public function __construct($tempDir) |
29 | 32 | { |
30 | 33 | $this->tempDir = $tempDir; |
@@ -90,7 +93,7 @@ discard block |
||
90 | 93 | |
91 | 94 | /** |
92 | 95 | * @param $token |
93 | - * @param $fallback |
|
96 | + * @param \Closure $fallback |
|
94 | 97 | * @param string $action |
95 | 98 | * @return GuzzleHttp\Psr7\Stream |
96 | 99 | * @throws Fio\QueueLimitException |
@@ -142,6 +145,9 @@ discard block |
||
142 | 145 | } |
143 | 146 | } |
144 | 147 | |
148 | + /** |
|
149 | + * @param string $filename |
|
150 | + */ |
|
145 | 151 | private static function sleep($filename) |
146 | 152 | { |
147 | 153 | $criticalTime = time() - filemtime($filename); |
@@ -164,6 +170,9 @@ discard block |
||
164 | 170 | return self::$tokens[$key]; |
165 | 171 | } |
166 | 172 | |
173 | + /** |
|
174 | + * @param string $filename |
|
175 | + */ |
|
167 | 176 | private static function safeProtocol($filename) |
168 | 177 | { |
169 | 178 | return Utils\SafeStream::PROTOCOL . '://' . $filename; |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function download($token, $url) |
67 | 67 | { |
68 | - return $this->request($token, function (GuzzleHttp\Client $client) use ($url) { |
|
68 | + return $this->request($token, function(GuzzleHttp\Client $client) use ($url) { |
|
69 | 69 | return $client->request('GET', $url, $this->downloadOptions); |
70 | 70 | }, 'download'); |
71 | 71 | } |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | } |
84 | 84 | $newPost[] = ['name' => 'file', 'contents' => fopen($filename, 'r')]; |
85 | 85 | |
86 | - $response = $this->request($token, function (GuzzleHttp\Client $client) use ($url, $newPost) { |
|
86 | + $response = $this->request($token, function(GuzzleHttp\Client $client) use ($url, $newPost) { |
|
87 | 87 | return $client->request('POST', $url, [GuzzleHttp\RequestOptions::MULTIPART => $newPost]); |
88 | 88 | }, 'upload'); |
89 | 89 | return self::createXmlResponse($response); |
@@ -114,13 +114,13 @@ discard block |
||
114 | 114 | throw $e; |
115 | 115 | } elseif ($i >= $this->limitLoop) { |
116 | 116 | fclose($file); |
117 | - throw new Fio\QueueLimitException('You have limit up requests to server ' . $this->limitLoop); |
|
117 | + throw new Fio\QueueLimitException('You have limit up requests to server '.$this->limitLoop); |
|
118 | 118 | } |
119 | 119 | self::sleep($tempFile); |
120 | 120 | $next = true; |
121 | 121 | } catch (GuzzleHttp\Exception\ServerException $e) { |
122 | - if($e->hasResponse()) { |
|
123 | - self::detectDownloadResponse( $e->getResponse() ); |
|
122 | + if ($e->hasResponse()) { |
|
123 | + self::detectDownloadResponse($e->getResponse()); |
|
124 | 124 | } |
125 | 125 | throw new Fio\ServiceUnavailableException('Service is currently unavailable'); |
126 | 126 | } catch (GuzzleHttp\Exception\ConnectException $e) { |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | { |
171 | 171 | $key = substr($token, 10, -10); |
172 | 172 | if (!isset(self::$tokens[$key])) { |
173 | - self::$tokens[$key] = $this->tempDir . DIRECTORY_SEPARATOR . md5($key); |
|
173 | + self::$tokens[$key] = $this->tempDir.DIRECTORY_SEPARATOR.md5($key); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | return self::$tokens[$key]; |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | |
179 | 179 | private static function safeProtocol($filename) |
180 | 180 | { |
181 | - return Utils\SafeStream::PROTOCOL . '://' . $filename; |
|
181 | + return Utils\SafeStream::PROTOCOL.'://'.$filename; |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | { |
116 | 116 | $this->language = strtolower($lang); |
117 | 117 | if (!in_array($this->language, self::$langs)) { |
118 | - throw new InvalidArgumentException($this->language . ' avaible are ' . implode(', ', self::$langs)); |
|
118 | + throw new InvalidArgumentException($this->language.' avaible are '.implode(', ', self::$langs)); |
|
119 | 119 | } |
120 | 120 | return $this; |
121 | 121 | } |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | /** @return string */ |
124 | 124 | private function getUrl() |
125 | 125 | { |
126 | - return self::REST_URL . 'import/'; |
|
126 | + return self::REST_URL.'import/'; |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | $extension = strtolower($extension); |
138 | 138 | static $extensions = ['xml', 'abo']; |
139 | 139 | if (!in_array($extension, $extensions)) { |
140 | - throw new InvalidArgumentException('Unsupported file upload format: ' . $extension . ' avaible are ' . implode(', ', $extensions)); |
|
140 | + throw new InvalidArgumentException('Unsupported file upload format: '.$extension.' avaible are '.implode(', ', $extensions)); |
|
141 | 141 | } |
142 | 142 | $this->uploadExtension = $extension; |
143 | 143 | return $this; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | if (array_key_exists($name, $this->properties)) { |
28 | 28 | return $this->properties[$name]; |
29 | 29 | } |
30 | - throw new Fio\TransactionPropertyException('Property does not exists. ' . $name); |
|
30 | + throw new Fio\TransactionPropertyException('Property does not exists. '.$name); |
|
31 | 31 | } |
32 | 32 | |
33 | 33 | public function clearTemporaryValues() |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | public function bindProperty($name, $type, $value) |
39 | 39 | { |
40 | - $method = 'set' . ucfirst($name); |
|
40 | + $method = 'set'.ucfirst($name); |
|
41 | 41 | if (method_exists($this, $method)) { |
42 | 42 | $value = $this->{$method}($value); |
43 | 43 | } elseif ($value !== null) { |