From e8b3a59e16fb8c0bcb7f9f23c34b02d1e16d830a Mon Sep 17 00:00:00 2001 From: TLingC <5617150+TLingC@users.noreply.github.com> Date: Sat, 29 Feb 2020 11:41:13 +0800 Subject: [PATCH 01/11] Remove useless method overriding #14 --- src/Exceptions/FailedActionException.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/Exceptions/FailedActionException.php b/src/Exceptions/FailedActionException.php index 63df0bf..fb06188 100644 --- a/src/Exceptions/FailedActionException.php +++ b/src/Exceptions/FailedActionException.php @@ -6,13 +6,4 @@ class FailedActionException extends Exception { - /** - * Create a new exception instance. - * - * @return void - */ - public function __construct($message) - { - parent::__construct($message); - } } From 73d135537c62404988257bde28d927089b9c5174 Mon Sep 17 00:00:00 2001 From: TLingC Date: Sat, 29 Feb 2020 23:24:19 +0800 Subject: [PATCH 02/11] Set resource attributes to protected #17 --- src/Resources/Egg.php | 7 ------- src/Resources/Location.php | 7 ------- src/Resources/Nest.php | 7 ------- src/Resources/Node.php | 7 ------- src/Resources/Resource.php | 2 +- src/Resources/Server.php | 7 ------- src/Resources/ServerDatabase.php | 7 ------- src/Resources/User.php | 7 ------- 8 files changed, 1 insertion(+), 50 deletions(-) diff --git a/src/Resources/Egg.php b/src/Resources/Egg.php index 6831d56..6af89e6 100644 --- a/src/Resources/Egg.php +++ b/src/Resources/Egg.php @@ -67,13 +67,6 @@ class Egg extends Resource */ public $script = []; - /** - * The attributes of the egg. - * - * @var array - */ - public $attributes = []; - /** * The date/time the egg was created. * diff --git a/src/Resources/Location.php b/src/Resources/Location.php index a1d2b7c..c0966c9 100644 --- a/src/Resources/Location.php +++ b/src/Resources/Location.php @@ -25,13 +25,6 @@ class Location extends Resource */ public $long; - /** - * The attributes of the location. - * - * @var array - */ - public $attributes = []; - /** * The date/time the location was created. * diff --git a/src/Resources/Nest.php b/src/Resources/Nest.php index a039763..d5e388e 100644 --- a/src/Resources/Nest.php +++ b/src/Resources/Nest.php @@ -39,13 +39,6 @@ class Nest extends Resource */ public $description; - /** - * The attributes of the nest. - * - * @var array - */ - public $attributes = []; - /** * The date/time the nest was created. * diff --git a/src/Resources/Node.php b/src/Resources/Node.php index c3995a8..a79fdb8 100644 --- a/src/Resources/Node.php +++ b/src/Resources/Node.php @@ -123,13 +123,6 @@ class Node extends Resource */ public $daemonBase; - /** - * The attributes of the node. - * - * @var array - */ - public $attributes = []; - /** * The date/time the node was created. * diff --git a/src/Resources/Resource.php b/src/Resources/Resource.php index cfae493..e72f593 100644 --- a/src/Resources/Resource.php +++ b/src/Resources/Resource.php @@ -11,7 +11,7 @@ class Resource * * @var array */ - public $attributes; + protected $attributes; /** * The Pterodactyl SDK instance. diff --git a/src/Resources/Server.php b/src/Resources/Server.php index f8a675a..173e16a 100644 --- a/src/Resources/Server.php +++ b/src/Resources/Server.php @@ -81,13 +81,6 @@ class Server extends Resource */ public $updatedAt; - /** - * The attributes of the server. - * - * @var array - */ - public $attributes = []; - /** * The limits of the server. * diff --git a/src/Resources/ServerDatabase.php b/src/Resources/ServerDatabase.php index d72fb78..e20a9bd 100644 --- a/src/Resources/ServerDatabase.php +++ b/src/Resources/ServerDatabase.php @@ -60,13 +60,6 @@ class ServerDatabase extends Resource */ public $updatedAt; - /** - * The attributes of the server. - * - * @var array - */ - public $attributes = []; - /** * Reset password of the given server's database. * diff --git a/src/Resources/User.php b/src/Resources/User.php index 3c4b13a..cd85785 100644 --- a/src/Resources/User.php +++ b/src/Resources/User.php @@ -81,13 +81,6 @@ class User extends Resource */ public $updatedAt; - /** - * The attributes of the user. - * - * @var array - */ - public $attributes = []; - /** * Delete the given user. * From 23c22d1ed4272d9e4124bf3c424e3245ab992447 Mon Sep 17 00:00:00 2001 From: TLingC Date: Sat, 29 Feb 2020 23:27:18 +0800 Subject: [PATCH 03/11] Fix #16 --- src/MakesHttpRequests.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/MakesHttpRequests.php b/src/MakesHttpRequests.php index 3f5a090..442e4b3 100644 --- a/src/MakesHttpRequests.php +++ b/src/MakesHttpRequests.php @@ -142,7 +142,9 @@ public function retry($timeout, $callback) beginning: - if ($output = $callback()) { + $output = $callback(); + + if ($output) { return $output; } From 752b52640b3f8837bc0fc070ac99e2a04b23b791 Mon Sep 17 00:00:00 2001 From: TLingC Date: Sun, 1 Mar 2020 10:49:40 +0800 Subject: [PATCH 04/11] Improve comments and param type restriction --- src/Actions/ManagesAllocations.php | 7 +++--- src/Actions/ManagesEggs.php | 4 ++-- src/Actions/ManagesLocations.php | 8 ++++--- src/Actions/ManagesNests.php | 4 +++- src/Actions/ManagesNodes.php | 8 ++++--- src/Actions/ManagesServers.php | 34 ++++++++++++++++-------------- src/Actions/ManagesUsers.php | 10 +++++---- src/Actions/UsesServers.php | 20 +++++++++++------- src/MakesHttpRequests.php | 2 +- src/Resources/Node.php | 2 +- src/Resources/Server.php | 22 +++++++++++++------ src/Resources/User.php | 2 ++ 12 files changed, 75 insertions(+), 48 deletions(-) diff --git a/src/Actions/ManagesAllocations.php b/src/Actions/ManagesAllocations.php index 684b2b1..60973df 100644 --- a/src/Actions/ManagesAllocations.php +++ b/src/Actions/ManagesAllocations.php @@ -10,10 +10,11 @@ trait ManagesAllocations * Get the collection of allocations for a given node. * * @param int $nodeId + * @param int $page * * @return array */ - public function allocations($nodeId, int $page = 1) + public function allocations(int $nodeId, int $page = 1) { $data = $this->get("api/application/nodes/$nodeId".'/allocations?page='.$page); $transform = $this->transformCollection( @@ -35,7 +36,7 @@ public function allocations($nodeId, int $page = 1) * * @return void */ - public function createAllocation($nodeId, array $data) + public function createAllocation(int $nodeId, array $data) { return $this->post("api/application/nodes/$nodeId/allocations", $data); } @@ -49,7 +50,7 @@ public function createAllocation($nodeId, array $data) * * @return void */ - public function deleteAllocation($nodeId, $allocationId) + public function deleteAllocation(int $nodeId, int $allocationId) { return $this->delete("api/application/nodes/$nodeId/allocations/$allocationId"); } diff --git a/src/Actions/ManagesEggs.php b/src/Actions/ManagesEggs.php index c671e80..31b7f46 100644 --- a/src/Actions/ManagesEggs.php +++ b/src/Actions/ManagesEggs.php @@ -13,7 +13,7 @@ trait ManagesEggs * * @return Egg[] */ - public function eggs($nestId) + public function eggs(int $nestId) { return $this->transformCollection( $this->get("api/application/nests/$nestId/eggs")['data'], @@ -29,7 +29,7 @@ public function eggs($nestId) * * @return Egg */ - public function egg($nestId, $eggId) + public function egg(int $nestId, int $eggId) { return new Egg($this->get("api/application/nests/$nestId/eggs/$eggId"), $this); } diff --git a/src/Actions/ManagesLocations.php b/src/Actions/ManagesLocations.php index 40b13da..3b6fbb1 100644 --- a/src/Actions/ManagesLocations.php +++ b/src/Actions/ManagesLocations.php @@ -9,6 +9,8 @@ trait ManagesLocations /** * Get a collection of locations. * + * @param int $page + * * @return array */ public function locations(int $page = 1) @@ -32,7 +34,7 @@ public function locations(int $page = 1) * * @return Location */ - public function location($locationId) + public function location(int $locationId) { return new Location($this->get("api/application/locations/$locationId"), $this); } @@ -57,7 +59,7 @@ public function createLocation(array $data) * * @return Location */ - public function updateLocation($locationId, array $data) + public function updateLocation(int $locationId, array $data) { return new Location($this->patch("api/application/locations/$locationId", $data), $this); } @@ -69,7 +71,7 @@ public function updateLocation($locationId, array $data) * * @return void */ - public function deleteLocation($locationId) + public function deleteLocation(int $locationId) { return $this->delete("api/application/locations/$locationId"); } diff --git a/src/Actions/ManagesNests.php b/src/Actions/ManagesNests.php index e0ace9c..e5fa34c 100644 --- a/src/Actions/ManagesNests.php +++ b/src/Actions/ManagesNests.php @@ -9,6 +9,8 @@ trait ManagesNests /** * Get a collection of nests. * + * @param int $page + * * @return array */ public function nests(int $page = 1) @@ -32,7 +34,7 @@ public function nests(int $page = 1) * * @return Nest */ - public function nest($nestId) + public function nest(int $nestId) { return new Nest($this->get("api/application/nests/$nestId"), $this); } diff --git a/src/Actions/ManagesNodes.php b/src/Actions/ManagesNodes.php index 72e5d4c..6caaa4c 100644 --- a/src/Actions/ManagesNodes.php +++ b/src/Actions/ManagesNodes.php @@ -9,6 +9,8 @@ trait ManagesNodes /** * Get a collection of nodes. * + * @param int $page + * * @return array */ public function nodes(int $page = 1) @@ -32,7 +34,7 @@ public function nodes(int $page = 1) * * @return Node */ - public function node($nodeId) + public function node(int $nodeId) { return new Node($this->get("api/application/nodes/$nodeId"), $this); } @@ -57,7 +59,7 @@ public function createNode(array $data) * * @return Node */ - public function updateNode($nodeId, array $data) + public function updateNode(int $nodeId, array $data) { return new Node($this->patch("api/application/nodes/$nodeId", $data), $this); } @@ -69,7 +71,7 @@ public function updateNode($nodeId, array $data) * * @return void */ - public function deleteNode($nodeId) + public function deleteNode(int $nodeId) { return $this->delete("api/application/nodes/$nodeId"); } diff --git a/src/Actions/ManagesServers.php b/src/Actions/ManagesServers.php index 19eed88..d79d09b 100644 --- a/src/Actions/ManagesServers.php +++ b/src/Actions/ManagesServers.php @@ -11,6 +11,8 @@ trait ManagesServers /** * Get the collection of servers. * + * @param int $page + * * @return array */ public function servers(int $page = 1) @@ -34,7 +36,7 @@ public function servers(int $page = 1) * * @return Server */ - public function server($serverId) + public function server(int $serverId) { $request = $this->get("api/application/servers/$serverId".'?include=allocations'); @@ -57,7 +59,7 @@ public function server($serverId) * * @return Server */ - public function serverEx($externalId) + public function serverEx(int $externalId) { $request = $this->get("api/application/servers/external/$externalId".'?include=allocations'); @@ -92,7 +94,7 @@ public function createServer(array $data) * * @return void */ - public function deleteServer($serverId) + public function deleteServer(int $serverId) { return $this->delete("api/application/servers/$serverId"); } @@ -104,7 +106,7 @@ public function deleteServer($serverId) * * @return void */ - public function forceDeleteServer($serverId) + public function forceDeleteServer(int $serverId) { return $this->delete("api/application/servers/$serverId/force"); } @@ -117,7 +119,7 @@ public function forceDeleteServer($serverId) * * @return Server */ - public function updateServerDetails($serverId, array $data) + public function updateServerDetails(int $serverId, array $data) { return new Server($this->patch("api/application/servers/$serverId/details", $data), $this); } @@ -130,7 +132,7 @@ public function updateServerDetails($serverId, array $data) * * @return Server */ - public function updateServerBuild($serverId, array $data) + public function updateServerBuild(int $serverId, array $data) { return new Server($this->patch("api/application/servers/$serverId/build", $data), $this); } @@ -143,7 +145,7 @@ public function updateServerBuild($serverId, array $data) * * @return Server */ - public function updateServerStartup($serverId, array $data) + public function updateServerStartup(int $serverId, array $data) { return new Server($this->patch("api/application/servers/$serverId/startup", $data), $this); } @@ -155,7 +157,7 @@ public function updateServerStartup($serverId, array $data) * * @return void */ - public function suspendServer($serverId) + public function suspendServer(int $serverId) { return $this->post("api/application/servers/$serverId/suspend"); } @@ -167,7 +169,7 @@ public function suspendServer($serverId) * * @return void */ - public function unsuspendServer($serverId) + public function unsuspendServer(int $serverId) { return $this->post("api/application/servers/$serverId/unsuspend"); } @@ -179,7 +181,7 @@ public function unsuspendServer($serverId) * * @return void */ - public function reinstallServer($serverId) + public function reinstallServer(int $serverId) { return $this->post("api/application/servers/$serverId/reinstall"); } @@ -191,7 +193,7 @@ public function reinstallServer($serverId) * * @return void */ - public function rebuildServer($serverId) + public function rebuildServer(int $serverId) { return $this->post("api/application/servers/$serverId/rebuild"); } @@ -203,7 +205,7 @@ public function rebuildServer($serverId) * * @return ServerDatabase[] */ - public function serverDatabases($serverId) + public function serverDatabases(int $serverId) { $data = $this->get("api/application/servers/$serverId/databases"); $transform = $this->transformCollection( @@ -222,7 +224,7 @@ public function serverDatabases($serverId) * * @return ServerDatabase */ - public function serverDatabase($serverId, $databaseId) + public function serverDatabase(int $serverId, int $databaseId) { return new ServerDatabase($this->get("api/application/servers/$serverId/databases/$databaseId"), $this); } @@ -235,7 +237,7 @@ public function serverDatabase($serverId, $databaseId) * * @return ServerDatabase */ - public function createServerDatabase($serverId, array $data) + public function createServerDatabase(int $serverId, array $data) { return new ServerDatabase($this->post("api/application/servers/$serverId/databases/", $data), $this); } @@ -248,7 +250,7 @@ public function createServerDatabase($serverId, array $data) * * @return void */ - public function resetServerDatabasePassword($serverId, $databaseId) + public function resetServerDatabasePassword(int $serverId, int $databaseId) { return $this->post("api/application/servers/$serverId/databases/$databaseId/reset-password"); } @@ -261,7 +263,7 @@ public function resetServerDatabasePassword($serverId, $databaseId) * * @return void */ - public function deleteServerDatabase($serverId, $databaseId) + public function deleteServerDatabase(int $serverId, int $databaseId) { return $this->delete("api/application/servers/$serverId/databases/$databaseId"); } diff --git a/src/Actions/ManagesUsers.php b/src/Actions/ManagesUsers.php index e6277aa..4b9d1d8 100644 --- a/src/Actions/ManagesUsers.php +++ b/src/Actions/ManagesUsers.php @@ -9,6 +9,8 @@ trait ManagesUsers /** * Get the collection of users. * + * @param int $page + * * @return array */ public function users(int $page = 1) @@ -32,7 +34,7 @@ public function users(int $page = 1) * * @return User */ - public function user($userId) + public function user(int $userId) { return new User($this->get("api/application/users/$userId"), $this); } @@ -44,7 +46,7 @@ public function user($userId) * * @return User */ - public function userEx($userExternalId) + public function userEx(int $userExternalId) { return new User($this->get("api/application/users/external/$userExternalId"), $this); } @@ -69,7 +71,7 @@ public function createUser(array $data) * * @return User */ - public function updateUser($userId, array $data) + public function updateUser(int $userId, array $data) { return new User($this->patch("api/application/users/$userId", $data), $this); } @@ -81,7 +83,7 @@ public function updateUser($userId, array $data) * * @return void */ - public function deleteUser($userId) + public function deleteUser(int $userId) { return $this->delete("api/application/users/$userId"); } diff --git a/src/Actions/UsesServers.php b/src/Actions/UsesServers.php index f80b2f2..5445f28 100644 --- a/src/Actions/UsesServers.php +++ b/src/Actions/UsesServers.php @@ -10,6 +10,8 @@ trait UsesServers /** * Get the collection of servers for the authenticated user. * + * @param int $page + * * @return array */ public function listServers(int $page = 1) @@ -29,9 +31,11 @@ public function listServers(int $page = 1) /** * Gets the details of a given server. * + * @param string $serverIdentifier + * * @return Server[] */ - public function getServer($serverIdentifier) + public function getServer(string $serverIdentifier) { $request = $this->get("api/client/servers/$serverIdentifier"); $server = new Server($request, $this); @@ -42,12 +46,12 @@ public function getServer($serverIdentifier) /** * Toggle the power on a given server. * - * @param string $serverId + * @param string $serverIdentifier * @param string $action * * @return void */ - public function powerServer($serverIdentifier, $action) + public function powerServer(string $serverIdentifier, string $action) { return $this->post("api/client/servers/$serverIdentifier/power", ['signal'=>"$action"]); } @@ -55,12 +59,12 @@ public function powerServer($serverIdentifier, $action) /** * Send a command to a given server. * - * @param string $serverId - * @param string $action + * @param string $serverIdentifier + * @param string $command * * @return void */ - public function commandServer($serverIdentifier, $command) + public function commandServer(string $serverIdentifier, string $command) { return $this->post("api/client/servers/$serverIdentifier/command", ['command'=>"$command"]); } @@ -68,11 +72,11 @@ public function commandServer($serverIdentifier, $command) /** * Get the utilization of a given server. * - * @param string $serverId + * @param string $serverIdentifier * * @return Stats[] */ - public function utilizationServer($serverIdentifier) + public function utilizationServer(string $serverIdentifier) { $request = $this->get("api/client/servers/$serverIdentifier/utilization"); $stats = new Stats($request, $this); diff --git a/src/MakesHttpRequests.php b/src/MakesHttpRequests.php index 442e4b3..0a90610 100644 --- a/src/MakesHttpRequests.php +++ b/src/MakesHttpRequests.php @@ -143,7 +143,7 @@ public function retry($timeout, $callback) beginning: $output = $callback(); - + if ($output) { return $output; } diff --git a/src/Resources/Node.php b/src/Resources/Node.php index a79fdb8..6dc5bde 100644 --- a/src/Resources/Node.php +++ b/src/Resources/Node.php @@ -190,7 +190,7 @@ public function createAllocation(array $data) * * @return void */ - public function deleteAllocation($allocationId) + public function deleteAllocation(int $allocationId) { return $this->pterodactyl->deleteAllocation($this->id, $allocationId); } diff --git a/src/Resources/Server.php b/src/Resources/Server.php index 173e16a..6fd4786 100644 --- a/src/Resources/Server.php +++ b/src/Resources/Server.php @@ -151,6 +151,8 @@ public function unsuspend() /** * Update details of the server. + * + * @param array $data * * @return void */ @@ -167,6 +169,8 @@ public function updateDetails(array $data = []) /** * Update build configuration of the server. * + * @param array $data + * * @return void */ public function updateBuild(array $data = []) @@ -183,6 +187,8 @@ public function updateBuild(array $data = []) /** * Update startup parameters of the server. * + * @param array $data + * * @return void */ public function updateStartup(array $data = []) @@ -221,19 +227,23 @@ public function rebuild() /** * Power the server. * + * @param string $action + * * @return void */ - public function power($action) + public function power(string $action) { return $this->pterodactyl->powerServer($this->identifier, $action); } /** - * Power the server. + * Send command to the server. * + * @param string $command + * * @return void */ - public function command($command) + public function command(string $command) { return $this->pterodactyl->commandServer($this->identifier, $command); } @@ -255,7 +265,7 @@ public function databases() * * @return ServerDatabase */ - public function database($databaseId) + public function database(int $databaseId) { return $this->pterodactyl->serverDatabase($this->id, $databaseId); } @@ -279,7 +289,7 @@ public function createDatabase(array $data) * * @return void */ - public function resetDatabasePassword($databaseId) + public function resetDatabasePassword(int $databaseId) { return $this->pterodactyl->resetServerDatabasePassword($this->id, $databaseId); } @@ -291,7 +301,7 @@ public function resetDatabasePassword($databaseId) * * @return void */ - public function deleteDatabase($databaseId) + public function deleteDatabase(int $databaseId) { return $this->pterodactyl->deleteServerDatabase($this->id, $databaseId); } diff --git a/src/Resources/User.php b/src/Resources/User.php index cd85785..250667d 100644 --- a/src/Resources/User.php +++ b/src/Resources/User.php @@ -94,6 +94,8 @@ public function delete() /** * Update the given user. * + * @param array $data + * * @return void */ public function update(array $data = []) From 01dd91c30b88552c216f6f72e8cb66a5dcdcb300 Mon Sep 17 00:00:00 2001 From: TLingC Date: Sun, 1 Mar 2020 02:55:01 +0000 Subject: [PATCH 05/11] Apply fixes from StyleCI --- src/Actions/ManagesLocations.php | 2 +- src/Actions/ManagesNests.php | 2 +- src/Actions/ManagesNodes.php | 2 +- src/Actions/ManagesServers.php | 2 +- src/Actions/ManagesUsers.php | 2 +- src/Actions/UsesServers.php | 4 ++-- src/Resources/Server.php | 10 +++++----- src/Resources/User.php | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Actions/ManagesLocations.php b/src/Actions/ManagesLocations.php index 3b6fbb1..3e3c723 100644 --- a/src/Actions/ManagesLocations.php +++ b/src/Actions/ManagesLocations.php @@ -10,7 +10,7 @@ trait ManagesLocations * Get a collection of locations. * * @param int $page - * + * * @return array */ public function locations(int $page = 1) diff --git a/src/Actions/ManagesNests.php b/src/Actions/ManagesNests.php index e5fa34c..cb8f04f 100644 --- a/src/Actions/ManagesNests.php +++ b/src/Actions/ManagesNests.php @@ -10,7 +10,7 @@ trait ManagesNests * Get a collection of nests. * * @param int $page - * + * * @return array */ public function nests(int $page = 1) diff --git a/src/Actions/ManagesNodes.php b/src/Actions/ManagesNodes.php index 6caaa4c..5f8b56c 100644 --- a/src/Actions/ManagesNodes.php +++ b/src/Actions/ManagesNodes.php @@ -10,7 +10,7 @@ trait ManagesNodes * Get a collection of nodes. * * @param int $page - * + * * @return array */ public function nodes(int $page = 1) diff --git a/src/Actions/ManagesServers.php b/src/Actions/ManagesServers.php index d79d09b..73d5a7b 100644 --- a/src/Actions/ManagesServers.php +++ b/src/Actions/ManagesServers.php @@ -12,7 +12,7 @@ trait ManagesServers * Get the collection of servers. * * @param int $page - * + * * @return array */ public function servers(int $page = 1) diff --git a/src/Actions/ManagesUsers.php b/src/Actions/ManagesUsers.php index 4b9d1d8..9516279 100644 --- a/src/Actions/ManagesUsers.php +++ b/src/Actions/ManagesUsers.php @@ -10,7 +10,7 @@ trait ManagesUsers * Get the collection of users. * * @param int $page - * + * * @return array */ public function users(int $page = 1) diff --git a/src/Actions/UsesServers.php b/src/Actions/UsesServers.php index 5445f28..b10364e 100644 --- a/src/Actions/UsesServers.php +++ b/src/Actions/UsesServers.php @@ -11,7 +11,7 @@ trait UsesServers * Get the collection of servers for the authenticated user. * * @param int $page - * + * * @return array */ public function listServers(int $page = 1) @@ -32,7 +32,7 @@ public function listServers(int $page = 1) * Gets the details of a given server. * * @param string $serverIdentifier - * + * * @return Server[] */ public function getServer(string $serverIdentifier) diff --git a/src/Resources/Server.php b/src/Resources/Server.php index 6fd4786..0348578 100644 --- a/src/Resources/Server.php +++ b/src/Resources/Server.php @@ -151,7 +151,7 @@ public function unsuspend() /** * Update details of the server. - * + * * @param array $data * * @return void @@ -170,7 +170,7 @@ public function updateDetails(array $data = []) * Update build configuration of the server. * * @param array $data - * + * * @return void */ public function updateBuild(array $data = []) @@ -188,7 +188,7 @@ public function updateBuild(array $data = []) * Update startup parameters of the server. * * @param array $data - * + * * @return void */ public function updateStartup(array $data = []) @@ -228,7 +228,7 @@ public function rebuild() * Power the server. * * @param string $action - * + * * @return void */ public function power(string $action) @@ -240,7 +240,7 @@ public function power(string $action) * Send command to the server. * * @param string $command - * + * * @return void */ public function command(string $command) diff --git a/src/Resources/User.php b/src/Resources/User.php index 250667d..55e4f2f 100644 --- a/src/Resources/User.php +++ b/src/Resources/User.php @@ -95,7 +95,7 @@ public function delete() * Update the given user. * * @param array $data - * + * * @return void */ public function update(array $data = []) From f3442836324d3efc8ac62b55828473a583405d7e Mon Sep 17 00:00:00 2001 From: TLingC Date: Sat, 7 Mar 2020 12:24:39 +0800 Subject: [PATCH 06/11] Use new transformer --- src/Actions/ManagesAllocations.php | 11 +----- src/Actions/ManagesEggs.php | 7 ++-- src/Actions/ManagesLocations.php | 16 +++------ src/Actions/ManagesNests.php | 13 ++----- src/Actions/ManagesNodes.php | 17 +++------ src/Actions/ManagesServers.php | 57 ++++++------------------------ src/Actions/ManagesUsers.php | 19 +++------- src/Actions/UsesServers.php | 21 ++--------- src/MakesHttpRequests.php | 2 +- src/Pterodactyl.php | 44 +++++++++++++++++------ src/Resources/SubUser.php | 48 +++++++++++++++++++++++++ 11 files changed, 114 insertions(+), 141 deletions(-) create mode 100644 src/Resources/SubUser.php diff --git a/src/Actions/ManagesAllocations.php b/src/Actions/ManagesAllocations.php index 60973df..ae53af8 100644 --- a/src/Actions/ManagesAllocations.php +++ b/src/Actions/ManagesAllocations.php @@ -16,16 +16,7 @@ trait ManagesAllocations */ public function allocations(int $nodeId, int $page = 1) { - $data = $this->get("api/application/nodes/$nodeId".'/allocations?page='.$page); - $transform = $this->transformCollection( - $data['data'], - Allocation::class - ); - - return [ - 'data' => $transform, - 'meta' => $data['meta'], - ]; + return $this->get("api/application/nodes/$nodeId".'/allocations?page='.$page); } /** diff --git a/src/Actions/ManagesEggs.php b/src/Actions/ManagesEggs.php index 31b7f46..40bf38f 100644 --- a/src/Actions/ManagesEggs.php +++ b/src/Actions/ManagesEggs.php @@ -15,10 +15,7 @@ trait ManagesEggs */ public function eggs(int $nestId) { - return $this->transformCollection( - $this->get("api/application/nests/$nestId/eggs")['data'], - Egg::class - ); + return $this->get("api/application/nests/$nestId/eggs"); } /** @@ -31,6 +28,6 @@ public function eggs(int $nestId) */ public function egg(int $nestId, int $eggId) { - return new Egg($this->get("api/application/nests/$nestId/eggs/$eggId"), $this); + return $this->get("api/application/nests/$nestId/eggs/$eggId"); } } diff --git a/src/Actions/ManagesLocations.php b/src/Actions/ManagesLocations.php index 3e3c723..5735f95 100644 --- a/src/Actions/ManagesLocations.php +++ b/src/Actions/ManagesLocations.php @@ -16,15 +16,7 @@ trait ManagesLocations public function locations(int $page = 1) { $data = $this->get('api/application/locations?page='.$page); - $transform = $this->transformCollection( - $data['data'], - Location::class - ); - - return [ - 'data' => $transform, - 'meta' => $data['meta'], - ]; + return $this->transform($data); } /** @@ -36,7 +28,7 @@ public function locations(int $page = 1) */ public function location(int $locationId) { - return new Location($this->get("api/application/locations/$locationId"), $this); + return $this->get("api/application/locations/$locationId"); } /** @@ -48,7 +40,7 @@ public function location(int $locationId) */ public function createLocation(array $data) { - return new Location($this->post('api/application/locations', $data), $this); + return $this->post('api/application/locations', $data); } /** @@ -61,7 +53,7 @@ public function createLocation(array $data) */ public function updateLocation(int $locationId, array $data) { - return new Location($this->patch("api/application/locations/$locationId", $data), $this); + return $this->patch("api/application/locations/$locationId", $data); } /** diff --git a/src/Actions/ManagesNests.php b/src/Actions/ManagesNests.php index cb8f04f..5250577 100644 --- a/src/Actions/ManagesNests.php +++ b/src/Actions/ManagesNests.php @@ -15,16 +15,7 @@ trait ManagesNests */ public function nests(int $page = 1) { - $data = $this->get('api/application/nests?page='.$page); - $transform = $this->transformCollection( - $data['data'], - Nest::class - ); - - return [ - 'data' => $transform, - 'meta' => $data['meta'], - ]; + return $this->get('api/application/nests?page='.$page); } /** @@ -36,6 +27,6 @@ public function nests(int $page = 1) */ public function nest(int $nestId) { - return new Nest($this->get("api/application/nests/$nestId"), $this); + return $this->get("api/application/nests/$nestId"); } } diff --git a/src/Actions/ManagesNodes.php b/src/Actions/ManagesNodes.php index 5f8b56c..b0ccdf0 100644 --- a/src/Actions/ManagesNodes.php +++ b/src/Actions/ManagesNodes.php @@ -15,16 +15,7 @@ trait ManagesNodes */ public function nodes(int $page = 1) { - $data = $this->get('api/application/nodes?page='.$page); - $transform = $this->transformCollection( - $data['data'], - Node::class - ); - - return [ - 'data' => $transform, - 'meta' => $data['meta'], - ]; + return $this->get('api/application/nodes?page='.$page); } /** @@ -36,7 +27,7 @@ public function nodes(int $page = 1) */ public function node(int $nodeId) { - return new Node($this->get("api/application/nodes/$nodeId"), $this); + return $this->get("api/application/nodes/$nodeId"); } /** @@ -48,7 +39,7 @@ public function node(int $nodeId) */ public function createNode(array $data) { - return new Node($this->post('api/application/nodes', $data), $this); + return $this->post('api/application/nodes', $data); } /** @@ -61,7 +52,7 @@ public function createNode(array $data) */ public function updateNode(int $nodeId, array $data) { - return new Node($this->patch("api/application/nodes/$nodeId", $data), $this); + return $this->patch("api/application/nodes/$nodeId", $data); } /** diff --git a/src/Actions/ManagesServers.php b/src/Actions/ManagesServers.php index 73d5a7b..bfaf3f1 100644 --- a/src/Actions/ManagesServers.php +++ b/src/Actions/ManagesServers.php @@ -17,16 +17,7 @@ trait ManagesServers */ public function servers(int $page = 1) { - $data = $this->get('api/application/servers?page='.$page); - $transform = $this->transformCollection( - $data['data'], - Server::class - ); - - return [ - 'data' => $transform, - 'meta' => $data['meta'], - ]; + return $this->get('api/application/servers?page='.$page); } /** @@ -38,18 +29,7 @@ public function servers(int $page = 1) */ public function server(int $serverId) { - $request = $this->get("api/application/servers/$serverId".'?include=allocations'); - - $allocations = $this->transformCollection( - $request['attributes']['relationships']['allocations']['data'], - Allocation::class - ); - - $server = new Server($request, $this); - - $server->allocations = $allocations; - - return $server; + return $this->get("api/application/servers/$serverId".'?include=allocations,subusers'); } /** @@ -61,18 +41,7 @@ public function server(int $serverId) */ public function serverEx(int $externalId) { - $request = $this->get("api/application/servers/external/$externalId".'?include=allocations'); - - $allocations = $this->transformCollection( - $request['attributes']['relationships']['allocations']['data'], - Allocation::class - ); - - $server = new Server($request, $this); - - $server->allocations = $allocations; - - return $server; + return $this->get("api/application/servers/external/$externalId".'?include=allocations'); } /** @@ -84,7 +53,7 @@ public function serverEx(int $externalId) */ public function createServer(array $data) { - return new Server($this->post('api/application/servers', $data), $this); + return $this->post('api/application/servers', $data); } /** @@ -121,7 +90,7 @@ public function forceDeleteServer(int $serverId) */ public function updateServerDetails(int $serverId, array $data) { - return new Server($this->patch("api/application/servers/$serverId/details", $data), $this); + return $this->patch("api/application/servers/$serverId/details", $data); } /** @@ -134,7 +103,7 @@ public function updateServerDetails(int $serverId, array $data) */ public function updateServerBuild(int $serverId, array $data) { - return new Server($this->patch("api/application/servers/$serverId/build", $data), $this); + return $this->patch("api/application/servers/$serverId/build", $data); } /** @@ -147,7 +116,7 @@ public function updateServerBuild(int $serverId, array $data) */ public function updateServerStartup(int $serverId, array $data) { - return new Server($this->patch("api/application/servers/$serverId/startup", $data), $this); + return $this->patch("api/application/servers/$serverId/startup", $data); } /** @@ -207,13 +176,7 @@ public function rebuildServer(int $serverId) */ public function serverDatabases(int $serverId) { - $data = $this->get("api/application/servers/$serverId/databases"); - $transform = $this->transformCollection( - $data['data'], - ServerDatabase::class - ); - - return $transform; + return $this->get("api/application/servers/$serverId/databases"); } /** @@ -226,7 +189,7 @@ public function serverDatabases(int $serverId) */ public function serverDatabase(int $serverId, int $databaseId) { - return new ServerDatabase($this->get("api/application/servers/$serverId/databases/$databaseId"), $this); + return $this->get("api/application/servers/$serverId/databases/$databaseId"); } /** @@ -239,7 +202,7 @@ public function serverDatabase(int $serverId, int $databaseId) */ public function createServerDatabase(int $serverId, array $data) { - return new ServerDatabase($this->post("api/application/servers/$serverId/databases/", $data), $this); + return $this->post("api/application/servers/$serverId/databases/", $data); } /** diff --git a/src/Actions/ManagesUsers.php b/src/Actions/ManagesUsers.php index 9516279..e941c57 100644 --- a/src/Actions/ManagesUsers.php +++ b/src/Actions/ManagesUsers.php @@ -15,16 +15,7 @@ trait ManagesUsers */ public function users(int $page = 1) { - $data = $this->get('api/application/users?page='.$page); - $transform = $this->transformCollection( - $data['data'], - User::class - ); - - return [ - 'data' => $transform, - 'meta' => $data['meta'], - ]; + return $this->get('api/application/users?page='.$page); } /** @@ -36,7 +27,7 @@ public function users(int $page = 1) */ public function user(int $userId) { - return new User($this->get("api/application/users/$userId"), $this); + return $this->get("api/application/users/$userId"); } /** @@ -48,7 +39,7 @@ public function user(int $userId) */ public function userEx(int $userExternalId) { - return new User($this->get("api/application/users/external/$userExternalId"), $this); + return $this->get("api/application/users/external/$userExternalId"); } /** @@ -60,7 +51,7 @@ public function userEx(int $userExternalId) */ public function createUser(array $data) { - return new User($this->post('api/application/users', $data), $this); + return $this->post('api/application/users', $data); } /** @@ -73,7 +64,7 @@ public function createUser(array $data) */ public function updateUser(int $userId, array $data) { - return new User($this->patch("api/application/users/$userId", $data), $this); + return $this->patch("api/application/users/$userId", $data); } /** diff --git a/src/Actions/UsesServers.php b/src/Actions/UsesServers.php index b10364e..0a8047f 100644 --- a/src/Actions/UsesServers.php +++ b/src/Actions/UsesServers.php @@ -16,16 +16,7 @@ trait UsesServers */ public function listServers(int $page = 1) { - $data = $this->get('api/client?page='.$page); - $transform = $this->transformCollection( - $data['data'], - Server::class - ); - - return [ - 'data' => $transform, - 'meta' => $data['meta'], - ]; + return $this->get('api/client?page='.$page); } /** @@ -37,10 +28,7 @@ public function listServers(int $page = 1) */ public function getServer(string $serverIdentifier) { - $request = $this->get("api/client/servers/$serverIdentifier"); - $server = new Server($request, $this); - - return $server; + return $this->get("api/client/servers/$serverIdentifier"); } /** @@ -78,9 +66,6 @@ public function commandServer(string $serverIdentifier, string $command) */ public function utilizationServer(string $serverIdentifier) { - $request = $this->get("api/client/servers/$serverIdentifier/utilization"); - $stats = new Stats($request, $this); - - return $stats; + return $this->get("api/client/servers/$serverIdentifier/utilization"); } } diff --git a/src/MakesHttpRequests.php b/src/MakesHttpRequests.php index 0a90610..54f3f6f 100644 --- a/src/MakesHttpRequests.php +++ b/src/MakesHttpRequests.php @@ -103,7 +103,7 @@ private function request($verb, $uri, array $payload = []) $responseBody = (string) $response->getBody(); - return json_decode($responseBody, true) ?: $responseBody; + return $this->transform(json_decode($responseBody, true)) ?: $responseBody; } /** diff --git a/src/Pterodactyl.php b/src/Pterodactyl.php index cab3c6c..7437d03 100644 --- a/src/Pterodactyl.php +++ b/src/Pterodactyl.php @@ -69,19 +69,43 @@ public function __construct($apiKey, $baseUri, HttpClient $guzzle = null) } /** - * Transform the items of the collection to the given class. + * Transform response data to resources. * - * @param array $collection - * @param string $class - * @param array $extraData - * - * @return array + * @param array $response + * @return mixed */ - protected function transformCollection($collection, $class, $extraData = []) + protected function transform($response) { - return array_map(function ($data) use ($class, $extraData) { - return new $class($data + $extraData, $this); - }, $collection); + if (empty($response['object'])) { + return $response; + } + + switch ($response['object']) { + case 'list': + $data = array_map(function ($object) { + return $this->transform($object); + }, $response['data']); + + if (isset($response['meta'])) { + return [ + 'data' => $data, + 'meta' => $response['meta'] + ]; + } + return $data; + } + + if (isset($response['attributes']['relationships'])) { + $response['attributes']['relationships'] = array_map(function ($object) { + return $this->transform($object); + }, $response['attributes']['relationships']); + } + + $class = '\\HCGCloud\\Pterodactyl\\Resources\\' . ucwords($response['object']); + + $resource = class_exists($class) ? new $class($response['attributes'], $this) : $response['attributes']; + + return $resource; } /** diff --git a/src/Resources/SubUser.php b/src/Resources/SubUser.php new file mode 100644 index 0000000..709b9c6 --- /dev/null +++ b/src/Resources/SubUser.php @@ -0,0 +1,48 @@ + Date: Sat, 7 Mar 2020 04:32:10 +0000 Subject: [PATCH 07/11] Apply fixes from StyleCI --- src/Actions/ManagesLocations.php | 1 + src/Actions/ManagesServers.php | 1 - src/Pterodactyl.php | 6 ++++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Actions/ManagesLocations.php b/src/Actions/ManagesLocations.php index 5735f95..701aebd 100644 --- a/src/Actions/ManagesLocations.php +++ b/src/Actions/ManagesLocations.php @@ -16,6 +16,7 @@ trait ManagesLocations public function locations(int $page = 1) { $data = $this->get('api/application/locations?page='.$page); + return $this->transform($data); } diff --git a/src/Actions/ManagesServers.php b/src/Actions/ManagesServers.php index bfaf3f1..632db80 100644 --- a/src/Actions/ManagesServers.php +++ b/src/Actions/ManagesServers.php @@ -2,7 +2,6 @@ namespace HCGCloud\Pterodactyl\Actions; -use HCGCloud\Pterodactyl\Resources\Allocation; use HCGCloud\Pterodactyl\Resources\Server; use HCGCloud\Pterodactyl\Resources\ServerDatabase; diff --git a/src/Pterodactyl.php b/src/Pterodactyl.php index 7437d03..6251b1a 100644 --- a/src/Pterodactyl.php +++ b/src/Pterodactyl.php @@ -72,6 +72,7 @@ public function __construct($apiKey, $baseUri, HttpClient $guzzle = null) * Transform response data to resources. * * @param array $response + * * @return mixed */ protected function transform($response) @@ -89,9 +90,10 @@ protected function transform($response) if (isset($response['meta'])) { return [ 'data' => $data, - 'meta' => $response['meta'] + 'meta' => $response['meta'], ]; } + return $data; } @@ -101,7 +103,7 @@ protected function transform($response) }, $response['attributes']['relationships']); } - $class = '\\HCGCloud\\Pterodactyl\\Resources\\' . ucwords($response['object']); + $class = '\\HCGCloud\\Pterodactyl\\Resources\\'.ucwords($response['object']); $resource = class_exists($class) ? new $class($response['attributes'], $this) : $response['attributes']; From b349e2fc2118f72e4e4bb8d9f683f9523ca73c2e Mon Sep 17 00:00:00 2001 From: TLingC Date: Sat, 7 Mar 2020 12:32:49 +0800 Subject: [PATCH 08/11] Fix transform mistakes of locations --- src/Actions/ManagesLocations.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Actions/ManagesLocations.php b/src/Actions/ManagesLocations.php index 701aebd..20ad2f2 100644 --- a/src/Actions/ManagesLocations.php +++ b/src/Actions/ManagesLocations.php @@ -15,9 +15,7 @@ trait ManagesLocations */ public function locations(int $page = 1) { - $data = $this->get('api/application/locations?page='.$page); - - return $this->transform($data); + return $this->get('api/application/locations?page='.$page); } /** From f4553f7f2b1b3b1faa70baf3a9ee11ed1909765c Mon Sep 17 00:00:00 2001 From: TLingC Date: Sat, 7 Mar 2020 12:59:06 +0800 Subject: [PATCH 09/11] Allow custom includes #19 --- src/Actions/ManagesEggs.php | 5 +++-- src/Actions/ManagesLocations.php | 5 +++-- src/Actions/ManagesNests.php | 5 +++-- src/Actions/ManagesNodes.php | 5 +++-- src/Actions/ManagesServers.php | 10 ++++++---- src/Actions/ManagesUsers.php | 10 ++++++---- src/Actions/UsesServers.php | 5 +++-- src/Pterodactyl.php | 12 ++++++++++++ src/Resources/Nest.php | 5 +++-- 9 files changed, 42 insertions(+), 20 deletions(-) diff --git a/src/Actions/ManagesEggs.php b/src/Actions/ManagesEggs.php index 40bf38f..d868d0b 100644 --- a/src/Actions/ManagesEggs.php +++ b/src/Actions/ManagesEggs.php @@ -23,11 +23,12 @@ public function eggs(int $nestId) * * @param int $nestId * @param int $eggId + * @param array $includes * * @return Egg */ - public function egg(int $nestId, int $eggId) + public function egg(int $nestId, int $eggId, array $includes = []) { - return $this->get("api/application/nests/$nestId/eggs/$eggId"); + return $this->get("api/application/nests/$nestId/eggs/$eggId".$this->include($includes)); } } diff --git a/src/Actions/ManagesLocations.php b/src/Actions/ManagesLocations.php index 20ad2f2..6ad3d1e 100644 --- a/src/Actions/ManagesLocations.php +++ b/src/Actions/ManagesLocations.php @@ -22,12 +22,13 @@ public function locations(int $page = 1) * Get a location instance. * * @param int $locationId + * @param array $includes * * @return Location */ - public function location(int $locationId) + public function location(int $locationId, array $includes = []) { - return $this->get("api/application/locations/$locationId"); + return $this->get("api/application/locations/$locationId".$this->include($includes)); } /** diff --git a/src/Actions/ManagesNests.php b/src/Actions/ManagesNests.php index 5250577..91fb3f7 100644 --- a/src/Actions/ManagesNests.php +++ b/src/Actions/ManagesNests.php @@ -22,11 +22,12 @@ public function nests(int $page = 1) * Get a nest instance. * * @param int $nestId + * @param array $includes * * @return Nest */ - public function nest(int $nestId) + public function nest(int $nestId, array $includes = []) { - return $this->get("api/application/nests/$nestId"); + return $this->get("api/application/nests/$nestId".$this->include($includes)); } } diff --git a/src/Actions/ManagesNodes.php b/src/Actions/ManagesNodes.php index b0ccdf0..0037490 100644 --- a/src/Actions/ManagesNodes.php +++ b/src/Actions/ManagesNodes.php @@ -22,12 +22,13 @@ public function nodes(int $page = 1) * Get a node instance. * * @param int $nodeId + * @param array $includes * * @return Node */ - public function node(int $nodeId) + public function node(int $nodeId, array $includes = []) { - return $this->get("api/application/nodes/$nodeId"); + return $this->get("api/application/nodes/$nodeId".$this->include($includes)); } /** diff --git a/src/Actions/ManagesServers.php b/src/Actions/ManagesServers.php index 632db80..b71bd56 100644 --- a/src/Actions/ManagesServers.php +++ b/src/Actions/ManagesServers.php @@ -23,24 +23,26 @@ public function servers(int $page = 1) * Get a server instance. * * @param int $serverId + * @param array $includes * * @return Server */ - public function server(int $serverId) + public function server(int $serverId, array $includes = []) { - return $this->get("api/application/servers/$serverId".'?include=allocations,subusers'); + return $this->get("api/application/servers/$serverId".$this->include($includes)); } /** * Get a server instance by external id. * * @param int $externalId + * @param array $includes * * @return Server */ - public function serverEx(int $externalId) + public function serverEx(int $externalId, array $includes = []) { - return $this->get("api/application/servers/external/$externalId".'?include=allocations'); + return $this->get("api/application/servers/external/$externalId".$this->include($includes)); } /** diff --git a/src/Actions/ManagesUsers.php b/src/Actions/ManagesUsers.php index e941c57..2f8f287 100644 --- a/src/Actions/ManagesUsers.php +++ b/src/Actions/ManagesUsers.php @@ -22,24 +22,26 @@ public function users(int $page = 1) * Get a user instance. * * @param int $userId + * @param array $includes * * @return User */ - public function user(int $userId) + public function user(int $userId, array $includes = []) { - return $this->get("api/application/users/$userId"); + return $this->get("api/application/users/$userId".$this->include($includes)); } /** * Get a user instance by external id. * * @param int $userExternalId + * @param array $includes * * @return User */ - public function userEx(int $userExternalId) + public function userEx(int $userExternalId, array $includes = []) { - return $this->get("api/application/users/external/$userExternalId"); + return $this->get("api/application/users/external/$userExternalId".$this->include($includes)); } /** diff --git a/src/Actions/UsesServers.php b/src/Actions/UsesServers.php index 0a8047f..ac5411d 100644 --- a/src/Actions/UsesServers.php +++ b/src/Actions/UsesServers.php @@ -23,12 +23,13 @@ public function listServers(int $page = 1) * Gets the details of a given server. * * @param string $serverIdentifier + * @param array $includes * * @return Server[] */ - public function getServer(string $serverIdentifier) + public function getServer(string $serverIdentifier, array $includes = []) { - return $this->get("api/client/servers/$serverIdentifier"); + return $this->get("api/client/servers/$serverIdentifier".$this->include($includes)); } /** diff --git a/src/Pterodactyl.php b/src/Pterodactyl.php index 6251b1a..021a2db 100644 --- a/src/Pterodactyl.php +++ b/src/Pterodactyl.php @@ -110,6 +110,18 @@ protected function transform($response) return $resource; } + /** + * Transform include array to url parameter. + * + * @param array $includes + * + * @return string + */ + protected function include($includes) + { + return empty($includes) ? '' : '?include='.implode(',', $includes); + } + /** * Set a new timeout. * diff --git a/src/Resources/Nest.php b/src/Resources/Nest.php index d5e388e..42e04a7 100644 --- a/src/Resources/Nest.php +++ b/src/Resources/Nest.php @@ -67,11 +67,12 @@ public function eggs() * Get a egg instance in the given nest. * * @param int $eggId + * @param array $includes * * @return Egg */ - public function egg($eggId) + public function egg($eggId, array $includes = []) { - return $this->pterodactyl->egg($this->id, $eggId); + return $this->pterodactyl->egg($this->id, $eggId, $includes); } } From 6810ec3dccd0dd1171380ad07b1aae511ef7d8b3 Mon Sep 17 00:00:00 2001 From: TLingC Date: Sat, 7 Mar 2020 05:02:23 +0000 Subject: [PATCH 10/11] Apply fixes from StyleCI --- src/Actions/ManagesEggs.php | 4 ++-- src/Actions/ManagesLocations.php | 2 +- src/Actions/ManagesNests.php | 2 +- src/Actions/ManagesNodes.php | 2 +- src/Actions/ManagesServers.php | 4 ++-- src/Actions/ManagesUsers.php | 4 ++-- src/Actions/UsesServers.php | 2 +- src/Resources/Nest.php | 2 +- 8 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Actions/ManagesEggs.php b/src/Actions/ManagesEggs.php index d868d0b..8eca706 100644 --- a/src/Actions/ManagesEggs.php +++ b/src/Actions/ManagesEggs.php @@ -21,8 +21,8 @@ public function eggs(int $nestId) /** * Get a egg instance. * - * @param int $nestId - * @param int $eggId + * @param int $nestId + * @param int $eggId * @param array $includes * * @return Egg diff --git a/src/Actions/ManagesLocations.php b/src/Actions/ManagesLocations.php index 6ad3d1e..30b9230 100644 --- a/src/Actions/ManagesLocations.php +++ b/src/Actions/ManagesLocations.php @@ -21,7 +21,7 @@ public function locations(int $page = 1) /** * Get a location instance. * - * @param int $locationId + * @param int $locationId * @param array $includes * * @return Location diff --git a/src/Actions/ManagesNests.php b/src/Actions/ManagesNests.php index 91fb3f7..ce82c2f 100644 --- a/src/Actions/ManagesNests.php +++ b/src/Actions/ManagesNests.php @@ -21,7 +21,7 @@ public function nests(int $page = 1) /** * Get a nest instance. * - * @param int $nestId + * @param int $nestId * @param array $includes * * @return Nest diff --git a/src/Actions/ManagesNodes.php b/src/Actions/ManagesNodes.php index 0037490..7c2600e 100644 --- a/src/Actions/ManagesNodes.php +++ b/src/Actions/ManagesNodes.php @@ -21,7 +21,7 @@ public function nodes(int $page = 1) /** * Get a node instance. * - * @param int $nodeId + * @param int $nodeId * @param array $includes * * @return Node diff --git a/src/Actions/ManagesServers.php b/src/Actions/ManagesServers.php index b71bd56..ad011e2 100644 --- a/src/Actions/ManagesServers.php +++ b/src/Actions/ManagesServers.php @@ -22,7 +22,7 @@ public function servers(int $page = 1) /** * Get a server instance. * - * @param int $serverId + * @param int $serverId * @param array $includes * * @return Server @@ -35,7 +35,7 @@ public function server(int $serverId, array $includes = []) /** * Get a server instance by external id. * - * @param int $externalId + * @param int $externalId * @param array $includes * * @return Server diff --git a/src/Actions/ManagesUsers.php b/src/Actions/ManagesUsers.php index 2f8f287..6456269 100644 --- a/src/Actions/ManagesUsers.php +++ b/src/Actions/ManagesUsers.php @@ -21,7 +21,7 @@ public function users(int $page = 1) /** * Get a user instance. * - * @param int $userId + * @param int $userId * @param array $includes * * @return User @@ -34,7 +34,7 @@ public function user(int $userId, array $includes = []) /** * Get a user instance by external id. * - * @param int $userExternalId + * @param int $userExternalId * @param array $includes * * @return User diff --git a/src/Actions/UsesServers.php b/src/Actions/UsesServers.php index ac5411d..2aa1c27 100644 --- a/src/Actions/UsesServers.php +++ b/src/Actions/UsesServers.php @@ -23,7 +23,7 @@ public function listServers(int $page = 1) * Gets the details of a given server. * * @param string $serverIdentifier - * @param array $includes + * @param array $includes * * @return Server[] */ diff --git a/src/Resources/Nest.php b/src/Resources/Nest.php index 42e04a7..52993d4 100644 --- a/src/Resources/Nest.php +++ b/src/Resources/Nest.php @@ -66,7 +66,7 @@ public function eggs() /** * Get a egg instance in the given nest. * - * @param int $eggId + * @param int $eggId * @param array $includes * * @return Egg From ba5a2669812e3110a8e46e405adceed8fbed33c6 Mon Sep 17 00:00:00 2001 From: TLingC Date: Sat, 7 Mar 2020 13:05:43 +0800 Subject: [PATCH 11/11] Set default includes for calling server api --- src/Actions/ManagesServers.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Actions/ManagesServers.php b/src/Actions/ManagesServers.php index ad011e2..a2232d8 100644 --- a/src/Actions/ManagesServers.php +++ b/src/Actions/ManagesServers.php @@ -27,7 +27,7 @@ public function servers(int $page = 1) * * @return Server */ - public function server(int $serverId, array $includes = []) + public function server(int $serverId, array $includes = ['allocations']) { return $this->get("api/application/servers/$serverId".$this->include($includes)); } @@ -40,7 +40,7 @@ public function server(int $serverId, array $includes = []) * * @return Server */ - public function serverEx(int $externalId, array $includes = []) + public function serverEx(int $externalId, array $includes = ['allocations']) { return $this->get("api/application/servers/external/$externalId".$this->include($includes)); }