|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App\Console\Commands; |
|
6
|
|
|
|
|
7
|
|
|
use App\Models\SteamApp; |
|
8
|
|
|
use App\Services\SteamService; |
|
|
|
|
|
|
9
|
|
|
use Illuminate\Console\Command; |
|
10
|
|
|
|
|
11
|
|
|
use function Laravel\Prompts\progress; |
|
12
|
|
|
use function Laravel\Prompts\info; |
|
13
|
|
|
use function Laravel\Prompts\warning; |
|
14
|
|
|
use function Laravel\Prompts\table; |
|
15
|
|
|
|
|
16
|
|
|
class SteamSearchGames extends Command |
|
17
|
|
|
{ |
|
18
|
|
|
/** |
|
19
|
|
|
* The name and signature of the console command. |
|
20
|
|
|
* |
|
21
|
|
|
* @var string |
|
22
|
|
|
*/ |
|
23
|
|
|
protected $signature = 'steam:search |
|
24
|
|
|
{query : The search query} |
|
25
|
|
|
{--limit=10 : Maximum number of results}'; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* The console command description. |
|
29
|
|
|
* |
|
30
|
|
|
* @var string |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $description = 'Search for games in the local Steam database'; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* Execute the console command. |
|
36
|
|
|
*/ |
|
37
|
|
|
public function handle(SteamService $steamService): int |
|
38
|
|
|
{ |
|
39
|
|
|
$query = $this->argument('query'); |
|
40
|
|
|
$limit = (int) $this->option('limit'); |
|
41
|
|
|
|
|
42
|
|
|
info("Searching for: {$query}"); |
|
43
|
|
|
|
|
44
|
|
|
$results = $steamService->searchMultiple($query, $limit); |
|
45
|
|
|
|
|
46
|
|
|
if ($results->isEmpty()) { |
|
47
|
|
|
warning('No games found matching your query.'); |
|
48
|
|
|
return Command::SUCCESS; |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
info("Found {$results->count()} result(s):"); |
|
52
|
|
|
|
|
53
|
|
|
$tableData = $results->map(fn($r) => [ |
|
54
|
|
|
$r['appid'], |
|
55
|
|
|
substr($r['name'], 0, 60), |
|
56
|
|
|
number_format($r['score'], 1) . '%', |
|
57
|
|
|
'https://store.steampowered.com/app/' . $r['appid'], |
|
58
|
|
|
])->toArray(); |
|
59
|
|
|
|
|
60
|
|
|
table( |
|
61
|
|
|
['App ID', 'Name', 'Score', 'Store URL'], |
|
62
|
|
|
$tableData |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
return Command::SUCCESS; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths