1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Xetaravel\Http\Middleware; |
||
6 | |||
7 | use Closure; |
||
8 | use GuzzleHttp\Client; |
||
9 | use Illuminate\Http\Request; |
||
10 | use Illuminate\Support\Facades\Cache; |
||
11 | |||
12 | class PackagistVersion |
||
13 | { |
||
14 | /** |
||
15 | * Handle an incoming request. |
||
16 | * |
||
17 | * @param Request $request |
||
18 | * @param Closure $next |
||
19 | * @param string|null $guard |
||
20 | * @return mixed |
||
21 | */ |
||
22 | public function handle(Request $request, Closure $next, string $guard = null): mixed |
||
0 ignored issues
–
show
|
|||
23 | { |
||
24 | $version = Cache::remember( |
||
25 | 'Packagist.version', |
||
26 | config('xetaravel.site.packagist_cache_timeout'), |
||
27 | function () { |
||
28 | $client = new Client(); |
||
29 | $res = $client->request('GET', config('xetaravel.site.packagist_url')); |
||
30 | if ($res->getStatusCode() !== 200) { |
||
31 | return false; |
||
32 | } |
||
33 | |||
34 | $array = json_decode($res->getBody()->getContents(), true); |
||
35 | |||
36 | return $array['packages']['xetaio/xetaravel'][0]['version']; |
||
37 | } |
||
38 | ); |
||
39 | |||
40 | config(['xetaravel.version' => $version]); |
||
41 | |||
42 | return $next($request); |
||
43 | } |
||
44 | } |
||
45 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.