From f52aa2e64f07e159ca351db3928ece21fa2523bb Mon Sep 17 00:00:00 2001 From: Sebastian Krupinski Date: Wed, 25 Feb 2026 00:16:38 -0500 Subject: [PATCH] refactor: standardize protocol Signed-off-by: Sebastian Krupinski --- lib/Controllers/DefaultController.php | 48 +++++++++++++-------------- lib/Manager.php | 2 +- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/lib/Controllers/DefaultController.php b/lib/Controllers/DefaultController.php index 36885ad..9dcfda9 100644 --- a/lib/Controllers/DefaultController.php +++ b/lib/Controllers/DefaultController.php @@ -41,7 +41,7 @@ class DefaultController extends ControllerAbstract { public function __construct( private readonly SessionTenant $tenantIdentity, private readonly SessionIdentity $userIdentity, - private Manager $chronoManager, + private readonly Manager $manager, private readonly LoggerInterface $logger, ) {} @@ -153,7 +153,7 @@ class DefaultController extends ControllerAbstract { $sources->jsonDeserialize($data['sources']); } - return $this->chronoManager->providerList($tenantId, $userId, $sources); + return $this->manager->providerList($tenantId, $userId, $sources); } @@ -166,7 +166,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER); } - return $this->chronoManager->providerFetch($tenantId, $userId, $data['identifier']); + return $this->manager->providerFetch($tenantId, $userId, $data['identifier']); } private function providerExtant(string $tenantId, string $userId, array $data): mixed { @@ -180,7 +180,7 @@ class DefaultController extends ControllerAbstract { $sources = new SourceSelector(); $sources->jsonDeserialize($data['sources']); - return $this->chronoManager->providerExtant($tenantId, $userId, $sources); + return $this->manager->providerExtant($tenantId, $userId, $sources); } @@ -195,7 +195,7 @@ class DefaultController extends ControllerAbstract { $sources->jsonDeserialize($data['sources']); } - return $this->chronoManager->serviceList($tenantId, $userId, $sources); + return $this->manager->serviceList($tenantId, $userId, $sources); } @@ -214,7 +214,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER); } - return $this->chronoManager->serviceFetch($tenantId, $userId, $data['provider'], $data['identifier']); + return $this->manager->serviceFetch($tenantId, $userId, $data['provider'], $data['identifier']); } private function serviceExtant(string $tenantId, string $userId, array $data): mixed { @@ -228,7 +228,7 @@ class DefaultController extends ControllerAbstract { $sources = new SourceSelector(); $sources->jsonDeserialize($data['sources']); - return $this->chronoManager->serviceExtant($tenantId, $userId, $sources); + return $this->manager->serviceExtant($tenantId, $userId, $sources); } private function serviceCreate(string $tenantId, string $userId, array $data): mixed { @@ -245,7 +245,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_DATA); } - return $this->chronoManager->serviceCreate( + return $this->manager->serviceCreate( $tenantId, $userId, $data['provider'], @@ -273,7 +273,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_DATA); } - return $this->chronoManager->serviceUpdate( + return $this->manager->serviceUpdate( $tenantId, $userId, $data['provider'], @@ -296,7 +296,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER); } - return $this->chronoManager->serviceDelete( + return $this->manager->serviceDelete( $tenantId, $userId, $data['provider'], @@ -317,7 +317,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException('Either a service identifier or location and identity must be provided for service test'); } - return $this->chronoManager->serviceTest( + return $this->manager->serviceTest( $tenantId, $userId, $data['provider'], @@ -339,7 +339,7 @@ class DefaultController extends ControllerAbstract { $filter = $data['filter'] ?? null; $sort = $data['sort'] ?? null; - return $this->chronoManager->collectionList($tenantId, $userId, $sources, $filter, $sort); + return $this->manager->collectionList($tenantId, $userId, $sources, $filter, $sort); } private function collectionExtant(string $tenantId, string $userId, array $data): mixed { @@ -353,7 +353,7 @@ class DefaultController extends ControllerAbstract { $sources = new SourceSelector(); $sources->jsonDeserialize($data['sources']); - return $this->chronoManager->collectionExtant($tenantId, $userId, $sources); + return $this->manager->collectionExtant($tenantId, $userId, $sources); } private function collectionFetch(string $tenantId, string $userId, array $data): mixed { @@ -376,7 +376,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_COLLECTION); } - return $this->chronoManager->collectionFetch( + return $this->manager->collectionFetch( $tenantId, $userId, $data['provider'], @@ -408,7 +408,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_DATA); } - return $this->chronoManager->collectionCreate( + return $this->manager->collectionCreate( $tenantId, $userId, $data['provider'], @@ -444,7 +444,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_DATA); } - return $this->chronoManager->collectionUpdate( + return $this->manager->collectionUpdate( $tenantId, $userId, $data['provider'], @@ -474,7 +474,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER); } - return $this->chronoManager->collectionDelete( + return $this->manager->collectionDelete( $tenantId, $userId, $data['provider'], @@ -501,7 +501,7 @@ class DefaultController extends ControllerAbstract { $sort = $data['sort'] ?? null; $range = $data['range'] ?? null; - return $this->chronoManager->entityList($tenantId, $userId, $sources, $filter, $sort, $range); + return $this->manager->entityList($tenantId, $userId, $sources, $filter, $sort, $range); } @@ -531,7 +531,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIERS); } - return $this->chronoManager->entityFetch( + return $this->manager->entityFetch( $tenantId, $userId, $data['provider'], @@ -552,7 +552,7 @@ class DefaultController extends ControllerAbstract { $sources = new SourceSelector(); $sources->jsonDeserialize($data['sources']); - return $this->chronoManager->entityExtant($tenantId, $userId, $sources); + return $this->manager->entityExtant($tenantId, $userId, $sources); } private function entityCreate(string $tenantId, string $userId, array $data = []): mixed { @@ -572,7 +572,7 @@ class DefaultController extends ControllerAbstract { } $options = $data['options'] ?? []; - return $this->chronoManager->entityCreate($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $properties, $options); + return $this->manager->entityCreate($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $properties, $options); } @@ -595,7 +595,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException('Invalid parameter: properties must be an array'); } - return $this->chronoManager->entityUpdate($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $data['identifier'], $properties); + return $this->manager->entityUpdate($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $data['identifier'], $properties); } @@ -614,7 +614,7 @@ class DefaultController extends ControllerAbstract { throw new InvalidArgumentException(self::ERR_INVALID_IDENTIFIER); } - return $this->chronoManager->entityDelete($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $data['identifier']); + return $this->manager->entityDelete($tenantId, $userId, $data['provider'], $data['service'], $data['collection'], $data['identifier']); } @@ -629,7 +629,7 @@ class DefaultController extends ControllerAbstract { $sources = new SourceSelector(); $sources->jsonDeserialize($data['sources']); - return $this->chronoManager->entityDelta($tenantId, $userId, $sources); + return $this->manager->entityDelta($tenantId, $userId, $sources); } } \ No newline at end of file diff --git a/lib/Manager.php b/lib/Manager.php index a605d27..82e8a82 100644 --- a/lib/Manager.php +++ b/lib/Manager.php @@ -217,7 +217,7 @@ class Manager { // retrieve provider and service $provider = $this->providerFetch($tenantId, $userId, $providerId); if ($provider instanceof ProviderServiceMutateInterface === false) { - throw new InvalidArgumentException("Provider '$providerId' does not support service creation"); + throw new InvalidArgumentException("Provider '$providerId' does not support service modification"); } // Fetch existing service