🐞 fix: phpcs issue cleanup

This commit is contained in:
Keith Solomon
2026-02-10 07:19:26 -06:00
parent d821a7e684
commit d8d6b34e90
7 changed files with 152 additions and 154 deletions

View File

@@ -57,129 +57,129 @@ try {
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset( $_POST['ship_action'] ) ) {
$action = (string) $_POST['ship_action'];
switch ($action) {
case 'orbit':
$client->orbitShip( $shipSymbol );
$statusMessage = 'Ship set to orbit.';
break;
case 'dock':
case 'orbit':
$client->orbitShip( $shipSymbol );
$statusMessage = 'Ship set to orbit.';
break;
case 'dock':
$client->dockShip( $shipSymbol );
$statusMessage = 'Ship docked.';
break;
case 'extract':
$client->extractResources( $shipSymbol );
$statusMessage = 'Resource extraction started.';
break;
case 'survey':
$client->surveyWaypoint( $shipSymbol );
$statusMessage = 'Survey completed.';
break;
case 'siphon':
$client->siphonResources( $shipSymbol );
$statusMessage = 'Siphon action completed.';
break;
case 'refuel':
$client->refuelShip( $shipSymbol );
$statusMessage = 'Ship refueled.';
break;
case 'sell_all_cargo':
$shipResponse = $client->getShip( $shipSymbol );
$shipData = $shipResponse['data'] ?? array();
$shipStatus = (string) ( $shipData['nav']['status'] ?? '' );
if ($shipStatus === 'IN_TRANSIT' ) {
throw new SpacetradersApiException( 'Ship is in transit and cannot sell cargo right now.' );
}
if ($shipStatus !== 'DOCKED' ) {
$client->dockShip( $shipSymbol );
$statusMessage = 'Ship docked.';
break;
case 'extract':
$client->extractResources( $shipSymbol );
$statusMessage = 'Resource extraction started.';
break;
case 'survey':
$client->surveyWaypoint( $shipSymbol );
$statusMessage = 'Survey completed.';
break;
case 'siphon':
$client->siphonResources( $shipSymbol );
$statusMessage = 'Siphon action completed.';
break;
case 'refuel':
$client->refuelShip( $shipSymbol );
$statusMessage = 'Ship refueled.';
break;
case 'sell_all_cargo':
$shipResponse = $client->getShip( $shipSymbol );
$shipData = $shipResponse['data'] ?? array();
$shipStatus = (string) ( $shipData['nav']['status'] ?? '' );
if ($shipStatus === 'IN_TRANSIT' ) {
throw new SpacetradersApiException( 'Ship is in transit and cannot sell cargo right now.' );
}
if ($shipStatus !== 'DOCKED' ) {
$client->dockShip( $shipSymbol );
}
$inventory = (array) ( $shipData['cargo']['inventory'] ?? array() );
$soldItems = 0;
foreach ( $inventory as $item ) {
$tradeSymbol = (string) ( $item['symbol'] ?? '' );
$units = (int) ( $item['units'] ?? 0 );
if ($tradeSymbol === '' || $units <= 0 ) {
continue;
}
try {
$client->sellCargo( $shipSymbol, $tradeSymbol, $units );
$soldItems++;
} catch (SpacetradersApiException $e) {
// Continue selling other items.
}
}
$statusMessage = 'Attempted to sell all cargo item types. Sold: ' . $soldItems . '.';
break;
case 'sell_cargo_item':
$tradeSymbol = trim( (string) ( $_POST['trade_symbol'] ?? '' ) );
$units = (int) ( $_POST['units'] ?? 0 );
}
$inventory = (array) ( $shipData['cargo']['inventory'] ?? array() );
$soldItems = 0;
foreach ( $inventory as $item ) {
$tradeSymbol = (string) ( $item['symbol'] ?? '' );
$units = (int) ( $item['units'] ?? 0 );
if ($tradeSymbol === '' || $units <= 0 ) {
throw new SpacetradersApiException( 'Trade symbol and units are required to sell cargo.' );
continue;
}
$shipResponse = $client->getShip( $shipSymbol );
$shipData = $shipResponse['data'] ?? array();
$shipStatus = (string) ( $shipData['nav']['status'] ?? '' );
if ($shipStatus === 'IN_TRANSIT' ) {
throw new SpacetradersApiException( 'Ship is in transit and cannot sell cargo right now.' );
try {
$client->sellCargo( $shipSymbol, $tradeSymbol, $units );
$soldItems++;
} catch (SpacetradersApiException $e) {
// Continue selling other items.
}
}
if ($shipStatus !== 'DOCKED' ) {
$client->dockShip( $shipSymbol );
}
$statusMessage = 'Attempted to sell all cargo item types. Sold: ' . $soldItems . '.';
break;
case 'sell_cargo_item':
$tradeSymbol = trim( (string) ( $_POST['trade_symbol'] ?? '' ) );
$units = (int) ( $_POST['units'] ?? 0 );
$client->sellCargo( $shipSymbol, $tradeSymbol, $units );
$statusMessage = 'Sold ' . number_format( $units ) . ' units of ' . $tradeSymbol . '.';
break;
case 'jettison_all_cargo':
$shipResponse = $client->getShip( $shipSymbol );
$shipData = $shipResponse['data'] ?? array();
$shipStatus = (string) ( $shipData['nav']['status'] ?? '' );
if ($shipStatus === 'IN_TRANSIT' ) {
throw new SpacetradersApiException( 'Ship is in transit and cannot jettison cargo right now.' );
}
if ($tradeSymbol === '' || $units <= 0 ) {
throw new SpacetradersApiException( 'Trade symbol and units are required to sell cargo.' );
}
$inventory = (array) ( $shipData['cargo']['inventory'] ?? array() );
$jettisonedItems = 0;
foreach ( $inventory as $item ) {
$tradeSymbol = (string) ( $item['symbol'] ?? '' );
$units = (int) ( $item['units'] ?? 0 );
if ($tradeSymbol === '' || $units <= 0 ) {
continue;
}
$shipResponse = $client->getShip( $shipSymbol );
$shipData = $shipResponse['data'] ?? array();
$shipStatus = (string) ( $shipData['nav']['status'] ?? '' );
try {
$client->jettisonCargo( $shipSymbol, $tradeSymbol, $units );
$jettisonedItems++;
} catch (SpacetradersApiException $e) {
// Continue attempting the rest.
}
}
if ($shipStatus === 'IN_TRANSIT' ) {
throw new SpacetradersApiException( 'Ship is in transit and cannot sell cargo right now.' );
}
$statusMessage = 'Attempted to jettison all cargo item types. Jettisoned: ' . $jettisonedItems . '.';
break;
case 'jettison_cargo_item':
$tradeSymbol = trim( (string) ( $_POST['trade_symbol'] ?? '' ) );
$units = (int) ( $_POST['units'] ?? 0 );
if ($shipStatus !== 'DOCKED' ) {
$client->dockShip( $shipSymbol );
}
$client->sellCargo( $shipSymbol, $tradeSymbol, $units );
$statusMessage = 'Sold ' . number_format( $units ) . ' units of ' . $tradeSymbol . '.';
break;
case 'jettison_all_cargo':
$shipResponse = $client->getShip( $shipSymbol );
$shipData = $shipResponse['data'] ?? array();
$shipStatus = (string) ( $shipData['nav']['status'] ?? '' );
if ($shipStatus === 'IN_TRANSIT' ) {
throw new SpacetradersApiException( 'Ship is in transit and cannot jettison cargo right now.' );
}
$inventory = (array) ( $shipData['cargo']['inventory'] ?? array() );
$jettisonedItems = 0;
foreach ( $inventory as $item ) {
$tradeSymbol = (string) ( $item['symbol'] ?? '' );
$units = (int) ( $item['units'] ?? 0 );
if ($tradeSymbol === '' || $units <= 0 ) {
throw new SpacetradersApiException( 'Trade symbol and units are required to jettison cargo.' );
continue;
}
$shipResponse = $client->getShip( $shipSymbol );
$shipData = $shipResponse['data'] ?? array();
$shipStatus = (string) ( $shipData['nav']['status'] ?? '' );
if ($shipStatus === 'IN_TRANSIT' ) {
throw new SpacetradersApiException( 'Ship is in transit and cannot jettison cargo right now.' );
try {
$client->jettisonCargo( $shipSymbol, $tradeSymbol, $units );
$jettisonedItems++;
} catch (SpacetradersApiException $e) {
// Continue attempting the rest.
}
}
$client->jettisonCargo( $shipSymbol, $tradeSymbol, $units );
$statusMessage = 'Jettisoned ' . number_format( $units ) . ' units of ' . $tradeSymbol . '.';
break;
$statusMessage = 'Attempted to jettison all cargo item types. Jettisoned: ' . $jettisonedItems . '.';
break;
case 'jettison_cargo_item':
$tradeSymbol = trim( (string) ( $_POST['trade_symbol'] ?? '' ) );
$units = (int) ( $_POST['units'] ?? 0 );
if ($tradeSymbol === '' || $units <= 0 ) {
throw new SpacetradersApiException( 'Trade symbol and units are required to jettison cargo.' );
}
$shipResponse = $client->getShip( $shipSymbol );
$shipData = $shipResponse['data'] ?? array();
$shipStatus = (string) ( $shipData['nav']['status'] ?? '' );
if ($shipStatus === 'IN_TRANSIT' ) {
throw new SpacetradersApiException( 'Ship is in transit and cannot jettison cargo right now.' );
}
$client->jettisonCargo( $shipSymbol, $tradeSymbol, $units );
$statusMessage = 'Jettisoned ' . number_format( $units ) . ' units of ' . $tradeSymbol . '.';
break;
}
if ($statusMessage !== '' ) {
@@ -284,7 +284,7 @@ try {
<button type="submit" name="ship_action" value="refuel" class="px-3 py-1 bg-amber-700 rounded hover:bg-amber-600">Refuel</button>
<?php endif; ?>
<?php if ( (int) ( $ship['cargo']['units'] ?? 0 ) > 0 ) : ?>
<?php if ((int) ( $ship['cargo']['units'] ?? 0 ) > 0) : ?>
<button type="submit" name="ship_action" value="sell_all_cargo" class="px-3 py-1 bg-rose-700 rounded hover:bg-rose-600">Sell All Cargo</button>
<button type="submit" name="ship_action" value="jettison_all_cargo" class="px-3 py-1 bg-red-800 rounded hover:bg-red-700">Jettison All Cargo</button>
<?php endif; ?>