🐞 fix: phpcs issue cleanup
This commit is contained in:
@@ -47,11 +47,7 @@ if (! isset( $tokenError ) ) {
|
||||
|
||||
try {
|
||||
if (! isset( $tokenError ) ) {
|
||||
if (
|
||||
$_SERVER['REQUEST_METHOD'] === 'POST' &&
|
||||
isset( $_POST['ship_type'] ) &&
|
||||
isset( $_POST['waypoint_symbol'] )
|
||||
) {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset( $_POST['ship_type'] ) && isset( $_POST['waypoint_symbol'] )) {
|
||||
$shipType = trim( (string) $_POST['ship_type'] );
|
||||
$waypointSymbol = trim( (string) $_POST['waypoint_symbol'] );
|
||||
|
||||
|
||||
@@ -1,8 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* Project runtime configuration values.
|
||||
* Spacetraders API Client Library - Project configuration
|
||||
*
|
||||
* @package Spacetraders
|
||||
* Runtime configuration values.
|
||||
*
|
||||
* @category Configuration
|
||||
* @package SpacetradersAPI
|
||||
* @author Keith Solomon <keith@keithsolomon.net>
|
||||
* @license MIT License
|
||||
* @version GIT: <git_id>
|
||||
* @link https://git.keithsolomon.net/keith/Spacetraders
|
||||
*/
|
||||
|
||||
return array(
|
||||
|
||||
@@ -1,24 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Spacetraders API Exception Class
|
||||
*
|
||||
* PHP version 7.4
|
||||
*
|
||||
* @category Exception
|
||||
* @package Spacetraders
|
||||
* @author Keith Solomon <keith@keithsolomon.net>
|
||||
* @license MIT License
|
||||
* @link https://github.com/your-repo/spacetraders
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom exception class for Spacetraders API related errors.
|
||||
* Spacetraders API Client Library - Exception class
|
||||
*
|
||||
* This exception is thrown when API calls to the Spacetraders service
|
||||
* encounter errors such as network issues, invalid responses, authentication
|
||||
* failures, or other API-specific problems.
|
||||
*
|
||||
* @category Exception
|
||||
* @package SpacetradersAPI
|
||||
* @author Keith Solomon <keith@keithsolomon.net>
|
||||
* @license MIT License
|
||||
* @version GIT: <git_id>
|
||||
* @link https://git.keithsolomon.net/keith/Spacetraders
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom exception class for Spacetraders API related errors.
|
||||
*
|
||||
* @extends RuntimeException
|
||||
*/
|
||||
class SpacetradersApiException extends RuntimeException {
|
||||
|
||||
@@ -7,11 +7,12 @@
|
||||
* It includes methods for authentication, making API requests, and handling responses,
|
||||
* making it easier to integrate Spacetraders into your applications or scripts.
|
||||
*
|
||||
* @category API
|
||||
* @package SpacetradersAPI
|
||||
* @author Keith Solomon <keith@keithsolomon.net>
|
||||
* @license MIT License
|
||||
* @version GIT: <git_id>
|
||||
* @link https://spacetraders.io
|
||||
* @link https://git.keithsolomon.net/keith/Spacetraders
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/spacetraders-api-exception.php';
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
<?php
|
||||
/**
|
||||
* Spacetraders SQLite storage for configuration and API cache.
|
||||
* Spacetraders API Client Library - Storage
|
||||
*
|
||||
* SQLite storage for configuration and API cache.
|
||||
*
|
||||
* @category Storage
|
||||
* @package SpacetradersAPI
|
||||
* @author Keith Solomon <keith@keithsolomon.net>
|
||||
* @license MIT License
|
||||
* @version GIT: <git_id>
|
||||
* @link https://git.keithsolomon.net/keith/Spacetraders
|
||||
*/
|
||||
|
||||
/**
|
||||
* Spacetraders SQLite storage for configuration and API cache.
|
||||
*
|
||||
* @package SpacetradersAPI
|
||||
* Storage for configuration and API cache.
|
||||
*/
|
||||
class SpacetradersStorage {
|
||||
/**
|
||||
@@ -45,7 +46,7 @@ class SpacetradersStorage {
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _initializeSchema(): void {
|
||||
private function _initializeSchema(): void { // phpcs:ignore
|
||||
$this->db->exec(
|
||||
'CREATE TABLE IF NOT EXISTS settings (
|
||||
setting_key TEXT PRIMARY KEY,
|
||||
|
||||
@@ -18,7 +18,7 @@ require_once __DIR__ . '/lib/spacetraders-storage.php';
|
||||
*
|
||||
* @return array<int,array<string,mixed>>
|
||||
*/
|
||||
function spacetraders_filter_mining_ships( array $ships ): array {
|
||||
function filterMiningShips( array $ships ): array {
|
||||
return array_values(
|
||||
array_filter(
|
||||
$ships,
|
||||
@@ -76,7 +76,7 @@ try {
|
||||
$agent = $agentResponse['data'] ?? $agentResponse;
|
||||
$ships = $shipsResponse['data'] ?? $shipsResponse;
|
||||
$contracts = $contractsResponse['data'] ?? $contractsResponse;
|
||||
$miningShips = spacetraders_filter_mining_ships( $ships );
|
||||
$miningShips = filterMiningShips( $ships );
|
||||
$activeContracts = array_values(
|
||||
array_filter(
|
||||
(array) $contracts,
|
||||
@@ -291,7 +291,7 @@ try {
|
||||
$contractsResponse = $client->listMyContracts();
|
||||
$ships = $shipsResponse['data'] ?? $shipsResponse;
|
||||
$contracts = $contractsResponse['data'] ?? $contractsResponse;
|
||||
$miningShips = spacetraders_filter_mining_ships( $ships );
|
||||
$miningShips = filterMiningShips( $ships );
|
||||
$activeContracts = array_values(
|
||||
array_filter(
|
||||
(array) $contracts,
|
||||
@@ -302,12 +302,7 @@ try {
|
||||
);
|
||||
}
|
||||
|
||||
if (
|
||||
$_SERVER['REQUEST_METHOD'] === 'POST' &&
|
||||
isset( $_POST['ship_action'] ) &&
|
||||
in_array( (string) $_POST['ship_action'], array( 'sell_ship_cargo', 'jettison_ship_cargo' ), true ) &&
|
||||
isset( $_POST['ship_symbol'] )
|
||||
) {
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset( $_POST['ship_action'] ) && in_array( (string) $_POST['ship_action'], array( 'sell_ship_cargo', 'jettison_ship_cargo' ), true ) && isset( $_POST['ship_symbol'] )) {
|
||||
$shipAction = (string) $_POST['ship_action'];
|
||||
$sellShipSymbol = trim( (string) $_POST['ship_symbol'] );
|
||||
|
||||
@@ -355,7 +350,7 @@ try {
|
||||
|
||||
$shipsResponse = $client->listMyShips();
|
||||
$ships = $shipsResponse['data'] ?? $shipsResponse;
|
||||
$miningShips = spacetraders_filter_mining_ships( $ships );
|
||||
$miningShips = filterMiningShips( $ships );
|
||||
} catch (SpacetradersApiException $e) {
|
||||
$errorMessage = $sellShipSymbol . ': ' . $e->getMessage();
|
||||
}
|
||||
|
||||
@@ -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; ?>
|
||||
|
||||
Reference in New Issue
Block a user