Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion .phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@

<rule ref="Squiz.ControlStructures.ControlSignature">
<properties>
<property name="requiredSpacesBeforeColon" value="0" />
<property name="requiredSpacesBeforeColon" value="1" />
</properties>
</rule>
<rule ref="PSR12.Functions.ReturnTypeDeclaration">
<exclude-pattern>src/Value/*</exclude-pattern>
</rule>
<rule ref="Squiz.Functions.MultiLineFunctionDeclaration.EmptyLine">
<exclude-pattern>src/Value/*</exclude-pattern>
</rule>

<rule ref="PSR12">
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.NewlineBeforeOpenBrace" />
<exclude name="PSR1.Methods.CamelCapsMethodName.NotCamelCaps" />
<exclude name="Squiz.Classes.ValidClassName.NotCamelCaps" />
<exclude name="Squiz.Functions.MultiLineFunctionDeclaration.Indent" />
<exclude name="Generic.WhiteSpace.ScopeIndent.Incorrect" />
</rule>

<rule ref="Generic.Files.LineLength">
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,13 @@ Get Info about your agent:
./spacetraders agent
```

Add the token to `.env` file to authenticate other requests.
Add the token to `.env` file to authenticate other requests.

## Branch Names

For any PR, the commit hook will check the following requirements for a branch name:

1. Must start with 'task/', 'bug/', or 'feature/'
2. Must include an issue number (digits) followed by a dash.
3. Must end with a descriptive slug (letters, numbers, dashes).

9 changes: 9 additions & 0 deletions bin/rector.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -e

CONTAINER="php"
docker compose run \
--rm \
--workdir /var/www \
"$CONTAINER" \
./vendor/bin/rector "$@"
8 changes: 5 additions & 3 deletions cli/Command/Fleet/ExtractShipController.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use Phparch\SpaceTradersCLI\Render;

#[HelpInfo(
description: "Extract mininerals at a waypoint.",
description: "Extract minerals at a waypoint.",
params: ['ship symbol']
)]
class ExtractShipController extends CommandController
Expand All @@ -30,7 +30,6 @@ public function handle(): void

try {
$response = $client->extractShip($shipSymbol);
//$response = $this->getMock();

$cooldown = new Render\Ship\Cooldown($response->cooldown);
echo $cooldown->output();
Expand All @@ -42,7 +41,10 @@ public function handle(): void
} catch (APIException $ex) {
$error = new Render\Exception($ex);
echo $error->output();
$cooldown = Value\Ship\CoolDown::fromArray($ex->data['cooldown']);

/** @var iterable<string, mixed> $raw */
$raw = $ex->data['cooldown'];
$cooldown = Value\Ship\CoolDown::fromArray($raw);
$render = new Render\Ship\Cooldown($cooldown);
echo $render->output();
}
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class Agent extends AbstractRenderer
{
public function __construct(
public \Phparch\SpaceTraders\Value\Agent $agent,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class Exception extends AbstractRenderer
{
public function __construct(
public \Exception $ex,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/GoodsDetailList.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class GoodsDetailList extends AbstractRenderer
public function __construct(
/** @var Detail[] $goods */
public array $goods,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/Market.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class Market extends AbstractRenderer
{
public function __construct(
public Value\Market $market,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/Market/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class Transaction extends AbstractRenderer
{
public function __construct(
public readonly Value\Market\Transaction $transaction,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/Market/TransactionsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ class TransactionsList extends AbstractRenderer
public function __construct(
/** @var Transaction[] $transactions */
public array $transactions,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/Ship/Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class Nav extends AbstractRenderer
{
public function __construct(
public \Phparch\SpaceTraders\Value\Ship\Nav $nav,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/Ship/RegistrationInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ class RegistrationInfo extends AbstractRenderer
{
public function __construct(
public \Phparch\SpaceTraders\Value\RegistrationInfo $info,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/TradeGoodsList.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ class TradeGoodsList extends AbstractRenderer
public function __construct(
/** @var TradeGoods[] */
public array $goods,
)
{
) {
}

public function output(): string
Expand Down
3 changes: 1 addition & 2 deletions cli/Render/Transaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ class Transaction extends AbstractRenderer
{
public function __construct(
public \Phparch\SpaceTraders\Value\Shipyard\Transaction $txn,
)
{
) {
}

public function output(): string
Expand Down
2 changes: 1 addition & 1 deletion cli/Render/Waypoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function output(): string
$this->sprintf(
'<:BLU:>SYSTEM SYMBOL:<:DEF:> %s, <:YEL:>%s<:DEF:> (x: %d, y: %d)',
$this->waypoint->symbol,
$this->waypoint->type,
$this->waypoint->type->value,
$this->waypoint->x,
$this->waypoint->y,
);
Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
],
"minimum-stability": "stable",
"require": {
"php": ">=8.3",
"php": ">=8.4",
"ext-readline": "*",
"ext-curl": "*",
"ext-apcu": "*",
"minicli/minicli": "^4.2",
"php-di/php-di": "^7.0",
"guzzlehttp/guzzle": "^7.8",
"vlucas/phpdotenv": "^5.6",
"cuyz/valinor": "^1.14",
"cuyz/valinor": "^2.3",
"predis/predis": "^2.3",
"kevinrob/guzzle-cache-middleware": "^5.1",
"symfony/cache": "^7.2",
Expand All @@ -45,15 +45,16 @@
"twig/twig": "^3.0"
},
"require-dev": {
"phpstan/phpstan": "^2.0",
"phpstan/phpstan": "^2.1",
"brainmaestro/composer-git-hooks": "^3.0",
"squizlabs/php_codesniffer": "^4.0",
"phpmd/phpmd": "3.x-dev",
"pdepend/pdepend": "3.x-dev",
"phpbench/phpbench": "^1.4",
"vincentlanglet/twig-cs-fixer": "^3.8",
"bmitch/churn-php": "^1.7",
"phparkitect/phparkitect": "^0.7.0"
"phparkitect/phparkitect": "^0.7.0",
"rector/rector": "^2.3"
},
"extra": {
"hooks": {
Expand All @@ -73,7 +74,7 @@
"check-code": ["@phpcs", "@phpstan", "@phparkitect"],
"phpmd": "vendor/bin/phpmd --ignore-violations-on-exit --ignore-errors-on-exit src text phpmd.xml" ,
"phpstan": "vendor/bin/phpstan --memory-limit=1G",
"phpcs": "vendor/bin/phpcs",
"phpcs": "vendor/bin/phpcs -s",
"phpcbf": "vendor/bin/phpcbf",
"churn": "vendor/bin/churn",
"phparkitect": "vendor/bin/phparkitect check",
Expand Down
Loading