From 91cba79a830f619f45b79cc2eeac6609f7f0aacd Mon Sep 17 00:00:00 2001 From: Walmir Silva Date: Sun, 13 Oct 2024 19:26:28 -0300 Subject: [PATCH] feat: integrate ProcessorRegistry interface into ProcessorBuilder - Refactored `ProcessorRegistry` to implement the `ProcessorRegistryContract` interface, ensuring compliance with contract standards. - Enhanced `ProcessorBuilder` to leverage `ProcessorRegistry` for dynamic processor retrieval and seamless configuration. - Improved `ProcessorBuilder` functionality to support both individual processor instantiation and the creation of processor pipelines for specified contexts. --- composer.lock | 14 +++++++------- src/ProcessorBuilder.php | 1 + src/ProcessorRegistry.php | 8 +++++--- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/composer.lock b/composer.lock index f16a07e..8dad95d 100644 --- a/composer.lock +++ b/composer.lock @@ -8,16 +8,16 @@ "packages": [ { "name": "kariricode/contract", - "version": "v2.7.0", + "version": "v2.7.1", "source": { "type": "git", "url": "https://github.com/KaririCode-Framework/kariricode-contract.git", - "reference": "96277f44c0e2c692100410053f01ed6f02164f3c" + "reference": "fed3014baa00e0d1527602bf1d1de1a31793f173" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/KaririCode-Framework/kariricode-contract/zipball/96277f44c0e2c692100410053f01ed6f02164f3c", - "reference": "96277f44c0e2c692100410053f01ed6f02164f3c", + "url": "https://api.github.com/repos/KaririCode-Framework/kariricode-contract/zipball/fed3014baa00e0d1527602bf1d1de1a31793f173", + "reference": "fed3014baa00e0d1527602bf1d1de1a31793f173", "shasum": "" }, "require": { @@ -66,7 +66,7 @@ "issues": "https://github.com/KaririCode-Framework/kariricode-contract/issues", "source": "https://github.com/KaririCode-Framework/kariricode-contract" }, - "time": "2024-10-13T20:28:43+00:00" + "time": "2024-10-13T22:20:45+00:00" }, { "name": "kariricode/data-structure", @@ -5047,12 +5047,12 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": {}, + "stability-flags": [], "prefer-stable": false, "prefer-lowest": false, "platform": { "php": "^8.3" }, - "platform-dev": {}, + "platform-dev": [], "plugin-api-version": "2.6.0" } diff --git a/src/ProcessorBuilder.php b/src/ProcessorBuilder.php index 05fe7ea..98fe3c9 100644 --- a/src/ProcessorBuilder.php +++ b/src/ProcessorBuilder.php @@ -7,6 +7,7 @@ use KaririCode\Contract\Processor\ConfigurableProcessor; use KaririCode\Contract\Processor\Pipeline; use KaririCode\Contract\Processor\Processor; +use KaririCode\Contract\Processor\ProcessorRegistry; class ProcessorBuilder { diff --git a/src/ProcessorRegistry.php b/src/ProcessorRegistry.php index d1f4576..d8f2cea 100644 --- a/src/ProcessorRegistry.php +++ b/src/ProcessorRegistry.php @@ -4,12 +4,14 @@ namespace KaririCode\ProcessorPipeline; +use KaririCode\Contract\DataStructure\Map; use KaririCode\Contract\Processor\Processor; +use KaririCode\Contract\Processor\ProcessorRegistry as ProcessorRegistryContract; use KaririCode\DataStructure\Map\HashMap; -class ProcessorRegistry +class ProcessorRegistry implements ProcessorRegistryContract { - public function __construct(private HashMap $processors = new HashMap()) + public function __construct(private Map $processors = new HashMap()) { } @@ -35,7 +37,7 @@ public function get(string $context, string $name): Processor return $contextMap->get($name); } - public function getContextProcessors(string $context): HashMap + public function getContextProcessors(string $context): Map { if (!$this->processors->containsKey($context)) { throw new \RuntimeException("Context '$context' not found.");