diff --git a/src/Orchestration/Adapter.php b/src/Orchestration/Adapter.php index 34326ec..81c957a 100644 --- a/src/Orchestration/Adapter.php +++ b/src/Orchestration/Adapter.php @@ -62,11 +62,10 @@ abstract public function listNetworks(): array; /** * Get usage stats of containers * - * @param string $container * @param array $filters * @return array<\Utopia\Orchestration\Container\Stats> */ - abstract public function getStats(string $container = null, array $filters = []): array; + abstract public function getStats(?string $container = null, array $filters = []): array; /** * Pull Image diff --git a/src/Orchestration/Adapter/DockerAPI.php b/src/Orchestration/Adapter/DockerAPI.php index 9680801..e12a063 100644 --- a/src/Orchestration/Adapter/DockerAPI.php +++ b/src/Orchestration/Adapter/DockerAPI.php @@ -15,12 +15,8 @@ class DockerAPI extends Adapter { /** * Constructor - * - * @param string $username - * @param string $password - * @param string $email */ - public function __construct(string $username = null, string $password = null, string $email = null) + public function __construct(?string $username = null, ?string $password = null, ?string $email = null) { if ($username && $password && $email) { $this->registryAuth = base64_encode(json_encode([ @@ -188,9 +184,9 @@ public function createNetwork(string $name, bool $internal = false): bool ]); if ($result['code'] === 409) { - throw new Orchestration('Network with name "' . $name . '" already exists: ' . $result['response']); + throw new Orchestration('Network with name "'.$name.'" already exists: '.$result['response']); } elseif ($result['code'] !== 201) { - throw new Orchestration('Error creating network: ' . $result['response']); + throw new Orchestration('Error creating network: '.$result['response']); } return $result['response']; @@ -256,11 +252,10 @@ public function networkDisconnect(string $container, string $network, bool $forc /** * Get usage stats of containers * - * @param string $container * @param array $filters * @return array */ - public function getStats(string $container = null, array $filters = []): array + public function getStats(?string $container = null, array $filters = []): array { // List ahead of time, since API does not allow listing all usage stats $containerIds = []; @@ -275,7 +270,7 @@ public function getStats(string $container = null, array $filters = []): array $list = []; foreach ($containerIds as $containerId) { - $result = $this->call('http://localhost/containers/' . $containerId . '/stats?stream=false', 'GET'); + $result = $this->call('http://localhost/containers/'.$containerId.'/stats?stream=false', 'GET'); if ($result['code'] !== 200) { throw new Orchestration($result['response']); diff --git a/src/Orchestration/Adapter/DockerCLI.php b/src/Orchestration/Adapter/DockerCLI.php index a24fc73..cd57630 100644 --- a/src/Orchestration/Adapter/DockerCLI.php +++ b/src/Orchestration/Adapter/DockerCLI.php @@ -15,11 +15,9 @@ class DockerCLI extends Adapter /** * Constructor * - * @param string $username - * @param string $password * @return void */ - public function __construct(string $username = null, string $password = null) + public function __construct(?string $username = null, ?string $password = null) { if ($username && $password) { $output = ''; @@ -81,11 +79,10 @@ public function networkDisconnect(string $container, string $network, bool $forc /** * Get usage stats of containers * - * @param string $container * @param array $filters * @return array */ - public function getStats(string $container = null, array $filters = []): array + public function getStats(?string $container = null, array $filters = []): array { // List ahead of time, since docker stats does not allow filtering $containerIds = []; @@ -163,7 +160,7 @@ private function parseIOStats(string $stats) 'TiB' => 1000000000000, ]; - [ $inStr, $outStr ] = \explode(' / ', $stats); + [$inStr, $outStr] = \explode(' / ', $stats); $inUnit = null; $outUnit = null; diff --git a/src/Orchestration/Orchestration.php b/src/Orchestration/Orchestration.php index f12acf2..c6dcd4c 100644 --- a/src/Orchestration/Orchestration.php +++ b/src/Orchestration/Orchestration.php @@ -110,11 +110,10 @@ public function networkConnect(string $container, string $network): bool /** * Get usage stats of containers * - * @param string $container * @param array $filters * @return array<\Utopia\Orchestration\Container\Stats> */ - public function getStats(string $container = null, array $filters = []): array + public function getStats(?string $container = null, array $filters = []): array { return $this->adapter->getStats($container, $filters); }