@@ -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; |
@@ -70,11 +70,11 @@ discard block |
||
70 | 70 | }, 'download'); |
71 | 71 | } |
72 | 72 | |
73 | - /** |
|
74 | - * @return Pay\IResponse |
|
75 | - * @throws Fio\QueueLimitException |
|
76 | - * @throws Fio\ServiceUnavailableException |
|
77 | - */ |
|
73 | + /** |
|
74 | + * @return Pay\IResponse |
|
75 | + * @throws Fio\QueueLimitException |
|
76 | + * @throws Fio\ServiceUnavailableException |
|
77 | + */ |
|
78 | 78 | public function upload($url, $token, array $post, $filename) |
79 | 79 | { |
80 | 80 | $newPost = []; |
@@ -119,11 +119,11 @@ discard block |
||
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() ); |
|
124 | - } |
|
125 | - throw new Fio\ServiceUnavailableException('Service is currently unavailable'); |
|
126 | - } |
|
122 | + if($e->hasResponse()) { |
|
123 | + self::detectDownloadResponse( $e->getResponse() ); |
|
124 | + } |
|
125 | + throw new Fio\ServiceUnavailableException('Service is currently unavailable'); |
|
126 | + } |
|
127 | 127 | } while ($next); |
128 | 128 | fclose($file); |
129 | 129 | touch($tempFile); |
@@ -135,11 +135,11 @@ discard block |
||
135 | 135 | return $response->getBody(); |
136 | 136 | } |
137 | 137 | |
138 | - /** |
|
139 | - * @param $response |
|
140 | - * @throws Fio\ServiceUnavailableException |
|
141 | - */ |
|
142 | - private static function detectDownloadResponse($response) |
|
138 | + /** |
|
139 | + * @param $response |
|
140 | + * @throws Fio\ServiceUnavailableException |
|
141 | + */ |
|
142 | + private static function detectDownloadResponse($response) |
|
143 | 143 | { |
144 | 144 | /* @var $contentTypeHeaders array */ |
145 | 145 | $contentTypeHeaders = $response->getHeader('Content-Type'); |
@@ -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 | } |
@@ -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 | /** |
@@ -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; |
@@ -28,10 +28,10 @@ discard block |
||
28 | 28 | $this->xmlFile = $xmlFile; |
29 | 29 | } |
30 | 30 | |
31 | - /** @return Pay\Payment\Euro |
|
32 | - * @throws InvalidArgumentException |
|
33 | - * @throws InvalidArgumentException |
|
34 | - */ |
|
31 | + /** @return Pay\Payment\Euro |
|
32 | + * @throws InvalidArgumentException |
|
33 | + * @throws InvalidArgumentException |
|
34 | + */ |
|
35 | 35 | public function createEuro($amount, $accountTo, $name) |
36 | 36 | { |
37 | 37 | return (new Pay\Payment\Euro($this->account)) |
@@ -40,9 +40,9 @@ discard block |
||
40 | 40 | ->setAmount($amount); |
41 | 41 | } |
42 | 42 | |
43 | - /** @return Pay\Payment\National |
|
44 | - * @throws InvalidArgumentException |
|
45 | - */ |
|
43 | + /** @return Pay\Payment\National |
|
44 | + * @throws InvalidArgumentException |
|
45 | + */ |
|
46 | 46 | public function createNational($amount, $accountTo, $bankCode = null) |
47 | 47 | { |
48 | 48 | return (new Pay\Payment\National($this->account)) |
@@ -50,9 +50,9 @@ discard block |
||
50 | 50 | ->setAmount($amount); |
51 | 51 | } |
52 | 52 | |
53 | - /** @return Pay\Payment\International |
|
54 | - * @throws InvalidArgumentException |
|
55 | - */ |
|
53 | + /** @return Pay\Payment\International |
|
54 | + * @throws InvalidArgumentException |
|
55 | + */ |
|
56 | 56 | public function createInternational($amount, $accountTo, $bic, $name, $street, $city, $country, $info) |
57 | 57 | { |
58 | 58 | return (new Pay\Payment\International($this->account)) |
@@ -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) { |
@@ -22,12 +22,12 @@ |
||
22 | 22 | $this->dateFormat = $dateFormat; |
23 | 23 | } |
24 | 24 | |
25 | - /** |
|
26 | - * @param $name |
|
27 | - * @return mixed |
|
28 | - * @throws Fio\TransactionPropertyException |
|
29 | - */ |
|
30 | - public function __get($name) |
|
25 | + /** |
|
26 | + * @param $name |
|
27 | + * @return mixed |
|
28 | + * @throws Fio\TransactionPropertyException |
|
29 | + */ |
|
30 | + public function __get($name) |
|
31 | 31 | { |
32 | 32 | if (array_key_exists($name, $this->properties)) { |
33 | 33 | return $this->properties[$name]; |
@@ -14,13 +14,13 @@ |
||
14 | 14 | /** @var string */ |
15 | 15 | private $token; |
16 | 16 | |
17 | - /** |
|
18 | - * FioAccount constructor. |
|
19 | - * @param $account |
|
20 | - * @param $token |
|
21 | - * @throws \h4kuna\Fio\AccountException |
|
22 | - */ |
|
23 | - public function __construct($account, $token) |
|
17 | + /** |
|
18 | + * FioAccount constructor. |
|
19 | + * @param $account |
|
20 | + * @param $token |
|
21 | + * @throws \h4kuna\Fio\AccountException |
|
22 | + */ |
|
23 | + public function __construct($account, $token) |
|
24 | 24 | { |
25 | 25 | $this->account = new Bank($account); |
26 | 26 | $this->token = $token; |
@@ -26,11 +26,11 @@ |
||
26 | 26 | return self::JSON; |
27 | 27 | } |
28 | 28 | |
29 | - /** |
|
30 | - * @param string $data |
|
31 | - * @return Read\TransactionList |
|
32 | - * @throws Nette\Utils\JsonException |
|
33 | - */ |
|
29 | + /** |
|
30 | + * @param string $data |
|
31 | + * @return Read\TransactionList |
|
32 | + * @throws Nette\Utils\JsonException |
|
33 | + */ |
|
34 | 34 | public function create($data) |
35 | 35 | { |
36 | 36 | if (!$data) { |
@@ -14,11 +14,11 @@ |
||
14 | 14 | const WAIT_TIME = 30; |
15 | 15 | const HEADER_CONFLICT = 409; |
16 | 16 | |
17 | - /** |
|
18 | - * @param $token |
|
19 | - * @param string $url |
|
20 | - * @return string raw data |
|
21 | - */ |
|
17 | + /** |
|
18 | + * @param $token |
|
19 | + * @param string $url |
|
20 | + * @return string raw data |
|
21 | + */ |
|
22 | 22 | public function download($token, $url); |
23 | 23 | |
24 | 24 | /** |
@@ -32,21 +32,21 @@ discard block |
||
32 | 32 | $this->temp = $temp ?: sys_get_temp_dir(); |
33 | 33 | } |
34 | 34 | |
35 | - /** |
|
36 | - * @param string $name Configured account name from AccountCollection |
|
37 | - * @return Fio\FioRead |
|
38 | - * @throws Fio\AccountException |
|
39 | - */ |
|
35 | + /** |
|
36 | + * @param string $name Configured account name from AccountCollection |
|
37 | + * @return Fio\FioRead |
|
38 | + * @throws Fio\AccountException |
|
39 | + */ |
|
40 | 40 | public function createFioRead($name = null) |
41 | 41 | { |
42 | 42 | return new Fio\FioRead($this->getQueue(), $this->getAccount($name), $this->createReader()); |
43 | 43 | } |
44 | 44 | |
45 | - /** |
|
46 | - * @param string $name Configured account name from AccountCollection |
|
47 | - * @return Fio\FioPay |
|
48 | - * @throws Fio\AccountException |
|
49 | - */ |
|
45 | + /** |
|
46 | + * @param string $name Configured account name from AccountCollection |
|
47 | + * @return Fio\FioPay |
|
48 | + * @throws Fio\AccountException |
|
49 | + */ |
|
50 | 50 | public function createFioPay($name = null) |
51 | 51 | { |
52 | 52 | return new Fio\FioPay( |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | return new Fio\Request\Queue($this->temp); |
64 | 64 | } |
65 | 65 | |
66 | - /** |
|
67 | - * @param array $accounts |
|
68 | - * @return Fio\Account\AccountCollection |
|
69 | - * @throws Fio\AccountException |
|
70 | - */ |
|
71 | - protected function createAccountCollection(array $accounts) |
|
66 | + /** |
|
67 | + * @param array $accounts |
|
68 | + * @return Fio\Account\AccountCollection |
|
69 | + * @throws Fio\AccountException |
|
70 | + */ |
|
71 | + protected function createAccountCollection(array $accounts) |
|
72 | 72 | { |
73 | 73 | return Fio\Account\AccountCollectionFactory::create($accounts); |
74 | 74 | } |
@@ -78,11 +78,11 @@ discard block |
||
78 | 78 | return $this->accountCollection; |
79 | 79 | } |
80 | 80 | |
81 | - /** |
|
82 | - * @param string $name Configured account name from AccountCollection |
|
83 | - * @return Fio\Account\FioAccount |
|
84 | - * @throws Fio\AccountException |
|
85 | - */ |
|
81 | + /** |
|
82 | + * @param string $name Configured account name from AccountCollection |
|
83 | + * @return Fio\Account\FioAccount |
|
84 | + * @throws Fio\AccountException |
|
85 | + */ |
|
86 | 86 | final protected function getAccount($name) |
87 | 87 | { |
88 | 88 | if ($name) { |