@@ -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) { |
@@ -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 | use Psr\Http\Message\ResponseInterface; |
10 | 10 | |
11 | 11 | class Queue implements IQueue |
@@ -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; |
@@ -60,7 +63,7 @@ discard block |
||
60 | 63 | /** |
61 | 64 | * @param $token |
62 | 65 | * @param string $url |
63 | - * @return mixed|string |
|
66 | + * @return \Psr\Http\Message\StreamInterface |
|
64 | 67 | * @throws Fio\QueueLimitException |
65 | 68 | * @throws Fio\ServiceUnavailableException |
66 | 69 | */ |
@@ -93,7 +96,7 @@ discard block |
||
93 | 96 | |
94 | 97 | /** |
95 | 98 | * @param $token |
96 | - * @param $fallback |
|
99 | + * @param \Closure $fallback |
|
97 | 100 | * @return ResponseInterface |
98 | 101 | * @throws Fio\QueueLimitException |
99 | 102 | * @throws Fio\ServiceUnavailableException |
@@ -151,6 +154,9 @@ discard block |
||
151 | 154 | } |
152 | 155 | } |
153 | 156 | |
157 | + /** |
|
158 | + * @param string $filename |
|
159 | + */ |
|
154 | 160 | private static function sleep($filename) |
155 | 161 | { |
156 | 162 | $criticalTime = time() - filemtime($filename); |
@@ -173,13 +179,16 @@ discard block |
||
173 | 179 | return self::$tokens[$key]; |
174 | 180 | } |
175 | 181 | |
182 | + /** |
|
183 | + * @param string $filename |
|
184 | + */ |
|
176 | 185 | private static function safeProtocol($filename) |
177 | 186 | { |
178 | 187 | return Utils\SafeStream::PROTOCOL . '://' . $filename; |
179 | 188 | } |
180 | 189 | |
181 | 190 | /** |
182 | - * @param ResponseInterface|GuzzleHttp\Psr7\Stream $response |
|
191 | + * @param ResponseInterface $response |
|
183 | 192 | * @return Pay\XMLResponse |
184 | 193 | */ |
185 | 194 | private static function createXmlResponse($response) |
@@ -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); |
@@ -115,12 +115,12 @@ discard block |
||
115 | 115 | throw $e; |
116 | 116 | } elseif ($i >= $this->limitLoop) { |
117 | 117 | fclose($file); |
118 | - throw new Fio\QueueLimitException('You have limit up requests to server ' . $this->limitLoop); |
|
118 | + throw new Fio\QueueLimitException('You have limit up requests to server '.$this->limitLoop); |
|
119 | 119 | } |
120 | 120 | self::sleep($tempFile); |
121 | 121 | $next = true; |
122 | 122 | } catch (GuzzleHttp\Exception\ServerException $e) { |
123 | - if($e->hasResponse()) { |
|
123 | + if ($e->hasResponse()) { |
|
124 | 124 | self::detectDownloadResponse($e->getResponse()); |
125 | 125 | } |
126 | 126 | throw self::createServiceUnavailableException(); |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | { |
168 | 168 | $key = substr($token, 10, -10); |
169 | 169 | if (!isset(self::$tokens[$key])) { |
170 | - self::$tokens[$key] = $this->tempDir . DIRECTORY_SEPARATOR . md5($key); |
|
170 | + self::$tokens[$key] = $this->tempDir.DIRECTORY_SEPARATOR.md5($key); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | return self::$tokens[$key]; |
@@ -175,7 +175,7 @@ discard block |
||
175 | 175 | |
176 | 176 | private static function safeProtocol($filename) |
177 | 177 | { |
178 | - return Utils\SafeStream::PROTOCOL . '://' . $filename; |
|
178 | + return Utils\SafeStream::PROTOCOL.'://'.$filename; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |