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

Commit b2d19ae

Browse files
Refactor type hints, formatting, and constants usage.
Updated method return types to allow nullable values, fixed formatting inconsistencies, and replaced string literals with enum constants for API paths. These changes improve code readability, maintainability, and alignment with coding standards.
1 parent c492889 commit b2d19ae

File tree

7 files changed

+15
-13
lines changed

7 files changed

+15
-13
lines changed

src/Abstract/AbstractApplication.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
ProcessManagement\RequestLimit
88
};
99
use UnitPhpSdk\Builders\EndpointBuilder;
10+
use UnitPhpSdk\Enums\ApiPathEnum;
1011
use UnitPhpSdk\Exceptions\UnitException;
1112
use UnitPhpSdk\Contracts\{ApplicationInterface, Arrayable, Uploadable};
1213
use UnitPhpSdk\Traits\CanUpload;
@@ -99,7 +100,7 @@ public function __construct(string $name, ?array $data = [])
99100
$this->parseFromArray($data);
100101
}
101102

102-
$this->setApiEndpoint(EndpointBuilder::create("config/applications/")->get() . $this->getName());
103+
$this->setApiEndpoint(EndpointBuilder::create(ApiPathEnum::APPLICATIONS->value)->get() . $this->getName());
103104
}
104105

105106
/**

src/Config/AccessLog.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use UnitPhpSdk\Builders\EndpointBuilder;
66
use UnitPhpSdk\Contracts\Arrayable;
77
use UnitPhpSdk\Contracts\Uploadable;
8+
use UnitPhpSdk\Enums\ApiPathEnum;
89
use UnitPhpSdk\Traits\CanUpload;
910

1011
class AccessLog implements Uploadable, Arrayable
@@ -27,12 +28,11 @@ class AccessLog implements Uploadable, Arrayable
2728

2829
public function __construct(
2930
array $data
30-
)
31-
{
31+
) {
3232
$this->path = $data['path'] ?? null;
3333
$this->format = $data['format'] ?? null;
3434

35-
$this->setApiEndpoint(EndpointBuilder::create('/config/access_log')->get());
35+
$this->setApiEndpoint(EndpointBuilder::create(ApiPathEnum::ACCESS_LOG->value)->get());
3636
}
3737

3838
/**

src/Config/Listener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,9 @@ public function setPass(ListenerPass $pass): void
147147
/**
148148
* Get tls section
149149
*
150-
* @return Tls
150+
* @return Tls|null
151151
*/
152-
public function getTls(): Tls
152+
public function getTls(): ?Tls
153153
{
154154
return $this->tls;
155155
}

src/Config/Route.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace UnitPhpSdk\Config;
44

5+
use Override;
56
use SplObjectStorage;
67
use UnitPhpSdk\Builders\EndpointBuilder;
78
use UnitPhpSdk\Config\Routes\RouteBlock;
@@ -63,6 +64,7 @@ public function getName(): string
6364

6465
/**
6566
* @param array $routeBlocks
67+
* @throws UnitException
6668
*/
6769
public function setRouteBlocks(array $routeBlocks): void
6870
{
@@ -99,7 +101,7 @@ public function getRouteBlocks(): array
99101
/**
100102
* @return array
101103
*/
102-
#[\Override] public function toArray(): array
104+
#[Override] public function toArray(): array
103105
{
104106
return array_map(fn (RouteBlock $routeBlock) => $routeBlock->toArray(), $this->getRouteBlocks());
105107
}
@@ -108,7 +110,7 @@ public function getRouteBlocks(): array
108110
* @param int $options
109111
* @return string
110112
*/
111-
#[\Override] public function toJson(int $options = 0): string
113+
#[Override] public function toJson(int $options = 0): string
112114
{
113115
return json_encode(array_filter($this->toArray(), fn ($item) => !empty($item)));
114116
}

src/Config/Settings.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,6 @@ public function setJsModule(array|string $js_module): void
125125
*/
126126
#[\Override] public function toJson(int $options = 0): string
127127
{
128-
return json_encode(array_filter($this->toArray(), fn($item) => !empty($item)), $options);
128+
return json_encode(array_filter($this->toArray(), fn ($item) => !empty($item)), $options);
129129
}
130130
}

src/Config/Settings/Telemetry.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ public function __construct(
3535
* @var TelemetryProtocolEnum $protocol
3636
*/
3737
private TelemetryProtocolEnum $protocol
38-
)
39-
{
38+
) {
4039
$this->setEndpoint($endpoint);
4140
$this->setProtocol($protocol);
4241
}
@@ -101,4 +100,4 @@ public function setSamplingRatio(?float $sampling_ratio): void
101100
{
102101
return json_encode($this->toArray(), $options);
103102
}
104-
}
103+
}

src/Contracts/ModuleStatisticsInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ public function getVersion(): string;
1717
* @return string
1818
*/
1919
public function getLibPath(): string;
20-
}
20+
}

0 commit comments

Comments
 (0)