@@ -11,5 +11,5 @@ |
||
11 | 11 | * @param array $options |
12 | 12 | * @return string |
13 | 13 | */ |
14 | - public function shorten($url, array $options = []); |
|
14 | + public function shorten($url, array $options = [ ]); |
|
15 | 15 | } |
@@ -11,5 +11,5 @@ |
||
11 | 11 | * @param array $options |
12 | 12 | * @return \GuzzleHttp\Promise\PromiseInterface |
13 | 13 | */ |
14 | - public function shortenAsync($url, array $options = []); |
|
14 | + public function shortenAsync($url, array $options = [ ]); |
|
15 | 15 | } |
@@ -9,7 +9,7 @@ |
||
9 | 9 | /** |
10 | 10 | * {@inheritDoc} |
11 | 11 | */ |
12 | - public function shorten($url, array $options = []) |
|
12 | + public function shorten($url, array $options = [ ]) |
|
13 | 13 | { |
14 | 14 | return $this->shortenAsync($url, $options)->wait(); |
15 | 15 | } |
@@ -29,12 +29,12 @@ |
||
29 | 29 | /** |
30 | 30 | * {@inheritDoc} |
31 | 31 | */ |
32 | - public function shortenAsync($url, array $options = []) |
|
32 | + public function shortenAsync($url, array $options = [ ]) |
|
33 | 33 | { |
34 | 34 | $options = array_merge(Arr::add(static::defaults, 'query.url', $url), $options); |
35 | 35 | $request = new Request('GET', '/api-create.php'); |
36 | 36 | |
37 | - return $this->client->sendAsync($request, $options)->then(function (ResponseInterface $response) { |
|
37 | + return $this->client->sendAsync($request, $options)->then(function(ResponseInterface $response) { |
|
38 | 38 | return str_replace('http://', 'https://', $response->getBody()->getContents()); |
39 | 39 | }); |
40 | 40 | } |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | $this->app->alias('url.shortener', UrlShortenerManager::class); |
49 | 49 | $this->app->bindIf(ClientInterface::class, Client::class); |
50 | 50 | |
51 | - $this->app->singleton('url.shortener', function ($app) { |
|
51 | + $this->app->singleton('url.shortener', function($app) { |
|
52 | 52 | return new UrlShortenerManager($app); |
53 | 53 | }); |
54 | 54 | } |
@@ -64,15 +64,15 @@ discard block |
||
64 | 64 | return; |
65 | 65 | } |
66 | 66 | |
67 | - UrlGenerator::macro('shorten', function (...$parameters) { |
|
67 | + UrlGenerator::macro('shorten', function(...$parameters) { |
|
68 | 68 | return app('url.shortener')->shorten(...$parameters); |
69 | 69 | }); |
70 | 70 | |
71 | - UrlGenerator::macro('shortenAsync', function (...$parameters) { |
|
71 | + UrlGenerator::macro('shortenAsync', function(...$parameters) { |
|
72 | 72 | return app('url.shortener')->shortenAsync(...$parameters); |
73 | 73 | }); |
74 | 74 | |
75 | - UrlGenerator::macro('shortener', function () { |
|
75 | + UrlGenerator::macro('shortener', function() { |
|
76 | 76 | return app('url.shortener'); |
77 | 77 | }); |
78 | 78 | } |
@@ -33,12 +33,12 @@ |
||
33 | 33 | /** |
34 | 34 | * {@inheritDoc} |
35 | 35 | */ |
36 | - public function shortenAsync($url, array $options = []) |
|
36 | + public function shortenAsync($url, array $options = [ ]) |
|
37 | 37 | { |
38 | 38 | $options = array_merge(Arr::add($this->defaults, 'query.s', $url), $options); |
39 | 39 | $request = new Request('GET', "/api/$this->token"); |
40 | 40 | |
41 | - return $this->client->sendAsync($request, $options)->then(function (ResponseInterface $response) { |
|
41 | + return $this->client->sendAsync($request, $options)->then(function(ResponseInterface $response) { |
|
42 | 42 | return $response->getBody()->getContents(); |
43 | 43 | }); |
44 | 44 | } |
@@ -31,8 +31,8 @@ discard block |
||
31 | 31 | public function __construct(Application $app) |
32 | 32 | { |
33 | 33 | $this->app = $app; |
34 | - $this->customCreators = []; |
|
35 | - $this->shorteners = []; |
|
34 | + $this->customCreators = [ ]; |
|
35 | + $this->shorteners = [ ]; |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | protected function callCustomCreator(array $config) |
45 | 45 | { |
46 | - return $this->customCreators[$config['driver']]($this->app, $config); |
|
46 | + return $this->customCreators[ $config[ 'driver' ] ]($this->app, $config); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function extend(string $name, Closure $callback) |
158 | 158 | { |
159 | - $this->customCreators[$name] = $callback->bindTo($this, $this); |
|
159 | + $this->customCreators[ $name ] = $callback->bindTo($this, $this); |
|
160 | 160 | |
161 | 161 | return $this; |
162 | 162 | } |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | */ |
169 | 169 | public function getDefaultDriver() |
170 | 170 | { |
171 | - return $this->app['config']['url-shortener.default']; |
|
171 | + return $this->app[ 'config' ][ 'url-shortener.default' ]; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function getShortenerConfig(string $name) |
181 | 181 | { |
182 | - return $this->app['config']["url-shortener.shorteners.$name"]; |
|
182 | + return $this->app[ 'config' ][ "url-shortener.shorteners.$name" ]; |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
@@ -196,16 +196,16 @@ discard block |
||
196 | 196 | throw new InvalidArgumentException("URL shortener [{$name}] is not defined"); |
197 | 197 | } |
198 | 198 | |
199 | - if (array_key_exists($config['driver'], $this->customCreators)) { |
|
199 | + if (array_key_exists($config[ 'driver' ], $this->customCreators)) { |
|
200 | 200 | return $this->callCustomCreator($config); |
201 | 201 | } |
202 | 202 | |
203 | - $driverMethod = 'create' . Str::studly($config['driver']) . 'Driver'; |
|
203 | + $driverMethod = 'create' . Str::studly($config[ 'driver' ]) . 'Driver'; |
|
204 | 204 | |
205 | 205 | if (method_exists($this, $driverMethod)) { |
206 | 206 | return $this->$driverMethod($config); |
207 | 207 | } |
208 | - throw new InvalidArgumentException("Driver [{$config['driver']}] is not supported"); |
|
208 | + throw new InvalidArgumentException("Driver [{$config[ 'driver' ]}] is not supported"); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | /** |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | */ |
217 | 217 | public function setDefaultDriver(string $name) |
218 | 218 | { |
219 | - $this->app['config']['url-shortener.default'] = $name; |
|
219 | + $this->app[ 'config' ][ 'url-shortener.default' ] = $name; |
|
220 | 220 | |
221 | 221 | return $this; |
222 | 222 | } |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | $name = $name ?: $this->getDefaultDriver(); |
230 | 230 | |
231 | 231 | if (array_key_exists($name, $this->shorteners)) { |
232 | - return $this->shorteners[$name]; |
|
232 | + return $this->shorteners[ $name ]; |
|
233 | 233 | } |
234 | 234 | |
235 | - return $this->shorteners[$name] = $this->resolve($name); |
|
235 | + return $this->shorteners[ $name ] = $this->resolve($name); |
|
236 | 236 | } |
237 | 237 | } |
@@ -49,12 +49,12 @@ |
||
49 | 49 | /** |
50 | 50 | * {@inheritDoc} |
51 | 51 | */ |
52 | - public function shortenAsync($url, array $options = []) |
|
52 | + public function shortenAsync($url, array $options = [ ]) |
|
53 | 53 | { |
54 | 54 | $options = array_merge_recursive(Arr::add($this->defaults, 'json.dynamicLinkInfo.link', $url), $options); |
55 | 55 | $request = new Request('POST', '/v1/shortLinks'); |
56 | 56 | |
57 | - return $this->client->sendAsync($request, $options)->then(function (ResponseInterface $response) { |
|
57 | + return $this->client->sendAsync($request, $options)->then(function(ResponseInterface $response) { |
|
58 | 58 | return json_decode($response->getBody()->getContents())->shortLink; |
59 | 59 | }); |
60 | 60 | } |
@@ -41,12 +41,12 @@ |
||
41 | 41 | /** |
42 | 42 | * {@inheritDoc} |
43 | 43 | */ |
44 | - public function shortenAsync($url, array $options = []) |
|
44 | + public function shortenAsync($url, array $options = [ ]) |
|
45 | 45 | { |
46 | 46 | $options = array_merge_recursive(Arr::add($this->defaults, 'json.long_url', $url), $options); |
47 | 47 | $request = new Request('POST', '/v4/shorten'); |
48 | 48 | |
49 | - return $this->client->sendAsync($request, $options)->then(function (ResponseInterface $response) { |
|
49 | + return $this->client->sendAsync($request, $options)->then(function(ResponseInterface $response) { |
|
50 | 50 | return str_replace('http://', 'https://', json_decode($response->getBody()->getContents())->link); |
51 | 51 | }); |
52 | 52 | } |