NNTmux /
newznab-tmux
| 1 | <?php |
||
| 2 | |||
| 3 | declare(strict_types=1); |
||
| 4 | |||
| 5 | namespace App\Console\Commands; |
||
| 6 | |||
| 7 | use App\Services\SteamService; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use Illuminate\Console\Command; |
||
| 9 | |||
| 10 | class SteamLookupGame extends Command |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * The name and signature of the console command. |
||
| 14 | * |
||
| 15 | * @var string |
||
| 16 | */ |
||
| 17 | protected $signature = 'steam:lookup |
||
| 18 | {title : The game title to search for} |
||
| 19 | {--details : Show full game details} |
||
| 20 | {--json : Output as JSON}'; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * The console command description. |
||
| 24 | * |
||
| 25 | * @var string |
||
| 26 | */ |
||
| 27 | protected $description = 'Look up a game on Steam by title'; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Execute the console command. |
||
| 31 | */ |
||
| 32 | public function handle(SteamService $steamService): int |
||
| 33 | { |
||
| 34 | $title = $this->argument('title'); |
||
| 35 | $showDetails = $this->option('details'); |
||
| 36 | $outputJson = $this->option('json'); |
||
| 37 | |||
| 38 | $this->info("Searching for: {$title}"); |
||
| 39 | $this->newLine(); |
||
| 40 | |||
| 41 | // Search for the game |
||
| 42 | $appId = $steamService->search($title); |
||
| 43 | |||
| 44 | if ($appId === null) { |
||
| 45 | $this->error('No matching game found.'); |
||
| 46 | return Command::FAILURE; |
||
| 47 | } |
||
| 48 | |||
| 49 | $this->info("Found game with Steam App ID: {$appId}"); |
||
| 50 | $this->newLine(); |
||
| 51 | |||
| 52 | if ($showDetails) { |
||
| 53 | $details = $steamService->getGameDetails($appId); |
||
| 54 | |||
| 55 | if ($details === false) { |
||
| 56 | $this->error('Could not retrieve game details.'); |
||
| 57 | return Command::FAILURE; |
||
| 58 | } |
||
| 59 | |||
| 60 | if ($outputJson) { |
||
| 61 | $this->line(json_encode($details, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); |
||
| 62 | } else { |
||
| 63 | $this->displayGameDetails($details); |
||
| 64 | } |
||
| 65 | |||
| 66 | // Get additional data |
||
| 67 | $reviews = $steamService->getReviewsSummary($appId); |
||
| 68 | $playerCount = $steamService->getPlayerCount($appId); |
||
| 69 | |||
| 70 | if ($reviews !== null) { |
||
| 71 | $this->newLine(); |
||
| 72 | $this->info('Reviews:'); |
||
| 73 | $this->table( |
||
| 74 | ['Metric', 'Value'], |
||
| 75 | [ |
||
| 76 | ['Rating', $reviews['review_score_desc'] ?? 'Unknown'], |
||
| 77 | ['Positive', number_format($reviews['total_positive'] ?? 0)], |
||
| 78 | ['Negative', number_format($reviews['total_negative'] ?? 0)], |
||
| 79 | ['Total', number_format($reviews['total_reviews'] ?? 0)], |
||
| 80 | ] |
||
| 81 | ); |
||
| 82 | } |
||
| 83 | |||
| 84 | if ($playerCount !== null) { |
||
| 85 | $this->info("Current Players: " . number_format($playerCount)); |
||
| 86 | } |
||
| 87 | } |
||
| 88 | |||
| 89 | return Command::SUCCESS; |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Display game details in a formatted way. |
||
| 94 | */ |
||
| 95 | protected function displayGameDetails(array $details): void |
||
| 96 | { |
||
| 97 | $this->info('=== Game Details ==='); |
||
| 98 | $this->newLine(); |
||
| 99 | |||
| 100 | // Basic info table |
||
| 101 | $basicInfo = [ |
||
| 102 | ['Title', $details['title'] ?? 'N/A'], |
||
| 103 | ['Steam ID', $details['steamid'] ?? 'N/A'], |
||
| 104 | ['Type', ucfirst($details['type'] ?? 'game')], |
||
| 105 | ['Publisher', $details['publisher'] ?? 'N/A'], |
||
| 106 | ['Developers', implode(', ', $details['developers'] ?? []) ?: 'N/A'], |
||
| 107 | ['Release Date', $details['releasedate'] ?? 'N/A'], |
||
| 108 | ['Genres', $details['genres'] ?? 'N/A'], |
||
| 109 | ['Platforms', implode(', ', $details['platforms'] ?? [])], |
||
| 110 | ]; |
||
| 111 | |||
| 112 | $this->table(['Property', 'Value'], $basicInfo); |
||
| 113 | |||
| 114 | // Scores |
||
| 115 | if (!empty($details['metacritic_score'])) { |
||
| 116 | $this->newLine(); |
||
| 117 | $this->info("Metacritic Score: {$details['metacritic_score']}"); |
||
| 118 | } |
||
| 119 | |||
| 120 | // Price |
||
| 121 | if (!empty($details['price'])) { |
||
| 122 | $price = $details['price']; |
||
| 123 | $this->newLine(); |
||
| 124 | $this->info('Pricing:'); |
||
| 125 | |||
| 126 | $priceInfo = [ |
||
| 127 | ['Currency', $price['currency'] ?? 'USD'], |
||
| 128 | ['Price', $price['final_formatted'] ?? sprintf('$%.2f', $price['final'] ?? 0)], |
||
| 129 | ]; |
||
| 130 | |||
| 131 | if (($price['discount_percent'] ?? 0) > 0) { |
||
| 132 | $priceInfo[] = ['Original', sprintf('$%.2f', $price['initial'] ?? 0)]; |
||
| 133 | $priceInfo[] = ['Discount', "{$price['discount_percent']}%"]; |
||
| 134 | } |
||
| 135 | |||
| 136 | $this->table(['Field', 'Value'], $priceInfo); |
||
| 137 | } |
||
| 138 | |||
| 139 | // Description |
||
| 140 | if (!empty($details['description'])) { |
||
| 141 | $this->newLine(); |
||
| 142 | $this->info('Description:'); |
||
| 143 | $this->line(wordwrap($details['description'], 80)); |
||
| 144 | } |
||
| 145 | |||
| 146 | // URLs |
||
| 147 | $this->newLine(); |
||
| 148 | $this->info('Links:'); |
||
| 149 | $this->line("Store: {$details['directurl']}"); |
||
| 150 | |||
| 151 | if (!empty($details['website'])) { |
||
| 152 | $this->line("Website: {$details['website']}"); |
||
| 153 | } |
||
| 154 | |||
| 155 | if (!empty($details['metacritic_url'])) { |
||
| 156 | $this->line("Metacritic: {$details['metacritic_url']}"); |
||
| 157 | } |
||
| 158 | |||
| 159 | // Stats |
||
| 160 | if (!empty($details['achievements']) || !empty($details['recommendations'])) { |
||
| 161 | $this->newLine(); |
||
| 162 | $this->info('Stats:'); |
||
| 163 | |||
| 164 | if (!empty($details['achievements'])) { |
||
| 165 | $this->line("Achievements: {$details['achievements']}"); |
||
| 166 | } |
||
| 167 | |||
| 168 | if (!empty($details['recommendations'])) { |
||
| 169 | $this->line("Recommendations: " . number_format($details['recommendations'])); |
||
| 170 | } |
||
| 171 | } |
||
| 172 | |||
| 173 | // Categories (multiplayer, etc.) |
||
| 174 | if (!empty($details['categories'])) { |
||
| 175 | $this->newLine(); |
||
| 176 | $this->info('Features:'); |
||
| 177 | $this->line(implode(', ', $details['categories'])); |
||
| 178 | } |
||
| 179 | } |
||
| 180 | } |
||
| 181 | |||
| 182 |
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