Skip to content
This repository was archived by the owner on Oct 22, 2025. It is now read-only.

Commit cbc94b5

Browse files
Refactor Unit class for cleaner code and improved HTTP request handling
- Removed redundant `loadConfig` call in `getConfig` for efficiency. - Updated `loadStatistics` to use `setMethod(HttpMethodsEnum::GET)` for clarity and standardization. - Adjusted formatting of `toArray` and `toJson` methods for better readability.
1 parent 2389b85 commit cbc94b5

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Unit.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,9 @@ public function __construct(
8080

8181
/**
8282
* @inheritDoc
83-
* @throws UnitException
8483
*/
8584
public function getConfig(): Contracts\ConfigInterface
8685
{
87-
$this->loadConfig();
88-
8986
return $this->config;
9087
}
9188

@@ -245,7 +242,9 @@ private function loadJsModules(): void
245242
*/
246243
private function loadStatistics(): void
247244
{
248-
$result = $this->request->send(ApiPathEnum::STATUS->value);
245+
$result = $this->request
246+
->setMethod(HttpMethodsEnum::GET)
247+
->send(ApiPathEnum::STATUS->value);
249248
$this->statistics = new Statistics($result);
250249
}
251250

@@ -350,7 +349,8 @@ public function restartApplication(AbstractApplication $application): bool
350349
/**
351350
* @throws UnitException
352351
*/
353-
#[Override] public function toArray(): array
352+
#[Override]
353+
public function toArray(): array
354354
{
355355
return [
356356
'certificates' => array_map(fn($certificate) => $certificate->toArray(), $this->getCertificates()),
@@ -376,7 +376,8 @@ public function isConnected(): bool
376376
return true;
377377
}
378378

379-
#[Override] public function toJson(int $options = 0): string
379+
#[Override]
380+
public function toJson(int $options = 0): string
380381
{
381382
return json_encode($this->toArray(), $options);
382383
}

0 commit comments

Comments
 (0)