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