Skip to content
This repository was archived by the owner on May 29, 2026. It is now read-only.

Commit 7ee06aa

Browse files
committed
chore(quality): fix PHPCS inline IFs, named-param, alignment
Fixes lint violations surfaced while running composer phpcs + phpmd on this branch: - lib/Service/ItemService.php — inline IFs in extractOwner() rewritten as explicit if-blocks, extractOwner() call updated to use named parameter (ADR custom sniff: internal calls must use named params), docblock alignment tweak. - lib/Controller/HealthController.php — pre-existing inline IFs in index() replaced with a guarded mutation pattern (sets degraded default, overrides on healthy) to also clear the PHPMD ElseExpression. - lib/Controller/MetricsController.php — pre-existing equals-sign alignment between $prefix and $healthy. `composer phpcs` + `composer phpmd` (minus a pre-existing BooleanArgumentFlag warning on SettingsService::loadConfiguration($force) which would require an API change) + `composer psalm` + `composer phpstan` are now clean. `composer test:unit` still reports 26 / 26 passing.
1 parent 34c57a6 commit 7ee06aa

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

lib/Controller/HealthController.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,12 @@ public function index(): JSONResponse
7676
{
7777
try {
7878
$openRegister = $this->settingsService->isOpenRegisterAvailable();
79-
$status = ($openRegister === true) ? 'ok' : 'degraded';
80-
$httpStatus = ($openRegister === true) ? Http::STATUS_OK : Http::STATUS_SERVICE_UNAVAILABLE;
79+
$status = 'degraded';
80+
$httpStatus = Http::STATUS_SERVICE_UNAVAILABLE;
81+
if ($openRegister === true) {
82+
$status = 'ok';
83+
$httpStatus = Http::STATUS_OK;
84+
}
8185

8286
return new JSONResponse(
8387
[

lib/Controller/MetricsController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function __construct(
7878
public function index(): DataDisplayResponse
7979
{
8080
try {
81-
$prefix = self::METRIC_PREFIX;
81+
$prefix = self::METRIC_PREFIX;
8282
$healthy = (int) $this->settingsService->isOpenRegisterAvailable();
8383

8484
$lines = [

lib/Service/ItemService.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public function delete(string $id, string $userId): string
146146
* OpenRegister owner of the object (via `@self.owner`).
147147
*
148148
* @param object|array<string,mixed> $object The object as returned by OpenRegister
149-
* (may be an entity or an associative array)
149+
* (may be an entity or an associative array)
150150
* @param string $userId The acting user's UID
151151
*
152152
* @return bool True if authorized, false otherwise.
@@ -159,7 +159,7 @@ private function isAuthorized(object|array $object, string $userId): bool
159159
return true;
160160
}
161161

162-
$owner = $this->extractOwner($object);
162+
$owner = $this->extractOwner(object: $object);
163163
return ($owner !== null && $owner === $userId);
164164
}//end isAuthorized()
165165

@@ -178,12 +178,20 @@ private function extractOwner(object|array $object): ?string
178178
{
179179
if (is_array($object) === true) {
180180
$self = ($object['@self'] ?? []);
181-
return is_array($self) === true ? (($self['owner'] ?? null)) : null;
181+
if (is_array($self) === true) {
182+
return ($self['owner'] ?? null);
183+
}
184+
185+
return null;
182186
}
183187

184188
if (method_exists($object, 'getOwner') === true) {
185189
$owner = $object->getOwner();
186-
return is_string($owner) === true ? $owner : null;
190+
if (is_string($owner) === true) {
191+
return $owner;
192+
}
193+
194+
return null;
187195
}
188196

189197
if (method_exists($object, 'jsonSerialize') === true) {

0 commit comments

Comments
 (0)