diff --git a/src/DataStructure/Behavioral/Indexable.php b/src/DataStructure/Behavioral/Indexable.php index d09e7bd..e291d02 100644 --- a/src/DataStructure/Behavioral/Indexable.php +++ b/src/DataStructure/Behavioral/Indexable.php @@ -21,11 +21,11 @@ interface Indexable /** * Retrieves an element at the specified index. * - * @param int $index The index of the element to retrieve + * @param mixed $index The index of the element to retrieve * * @return mixed The element at the specified index */ - public function get(int $index): mixed; + public function get(mixed $index): mixed; /** * Sets an element at the specified index. @@ -33,5 +33,5 @@ public function get(int $index): mixed; * @param int $index The index where the element should be set * @param mixed $element The element to set */ - public function set(int $index, mixed $element): void; + public function set(mixed $index, mixed $element): void; } diff --git a/src/Logging/LogHandler.php b/src/Logging/LogHandler.php index 20797d0..66dc6e8 100644 --- a/src/Logging/LogHandler.php +++ b/src/Logging/LogHandler.php @@ -37,6 +37,7 @@ public function handle(ImmutableValue $record): void; /** * Checks whether the handler is handling the given log level. + * * @param ImmutableValue $record the log record to be processed, represented as an associative array */ public function isHandling(ImmutableValue $record): bool; diff --git a/src/Logging/LogLevel.php b/src/Logging/LogLevel.php index ec7d050..dfff525 100644 --- a/src/Logging/LogLevel.php +++ b/src/Logging/LogLevel.php @@ -27,7 +27,14 @@ interface LogLevel public function getLevel(): string; /** - * Gets the log level as a int level + * Gets the color level as a string. + * + * @return string the color level + */ + public function getColor(): string; + + /** + * Gets the log level as a int level. * * @return int the log level */ diff --git a/src/Logging/LogRotator.php b/src/Logging/LogRotator.php index 16a0f8e..c128edd 100644 --- a/src/Logging/LogRotator.php +++ b/src/Logging/LogRotator.php @@ -21,6 +21,7 @@ interface LogRotator { public function shouldRotate(string $filePath): bool; + /** * Rotates a log file. * @@ -30,5 +31,4 @@ public function shouldRotate(string $filePath): bool; * @param string $filename the name of the log file to be rotated */ public function rotate(string $filename): void; - } diff --git a/src/Processor/ConfigurableProcessor.php b/src/Processor/ConfigurableProcessor.php new file mode 100644 index 0000000..84b3b37 --- /dev/null +++ b/src/Processor/ConfigurableProcessor.php @@ -0,0 +1,27 @@ + + * @license MIT + * + * @see https://kariricode.org/ + */ +interface ConfigurableProcessor extends Processor +{ + /** + * Configures the processor with the provided options. + * + * @param array $options The configuration options + */ + public function configure(array $options): void; +} diff --git a/src/Processor/Pipeline.php b/src/Processor/Pipeline.php new file mode 100644 index 0000000..57b6034 --- /dev/null +++ b/src/Processor/Pipeline.php @@ -0,0 +1,36 @@ + + * @license MIT + * + * @see https://kariricode.org/ + */ +interface Pipeline +{ + /** + * Adds a processor to the pipeline. + * + * @param Processor $processor The processor to be added + */ + public function addProcessor(Processor $processor): self; + + /** + * Executes the processing pipeline on the provided input. + * + * @param mixed $input The value to be processed by the pipeline + * + * @return mixed The final result after passing through all processors + */ + public function process(mixed $input): mixed; +} diff --git a/src/Processor/Processor.php b/src/Processor/Processor.php new file mode 100644 index 0000000..c1d865e --- /dev/null +++ b/src/Processor/Processor.php @@ -0,0 +1,29 @@ + + * @license MIT + * + * @see https://kariricode.org/ + */ +interface Processor +{ + /** + * Processes the provided input and returns the result. + * + * @param mixed $input The value to be processed + * + * @return mixed The result of the processing + */ + public function process(mixed $input): mixed; +} diff --git a/tests/Processor/ConfigurableProcessorTest.php b/tests/Processor/ConfigurableProcessorTest.php new file mode 100644 index 0000000..8c0b479 --- /dev/null +++ b/tests/Processor/ConfigurableProcessorTest.php @@ -0,0 +1,32 @@ +createMock(ConfigurableProcessor::class); + $mock->expects($this->once()) + ->method('configure') + ->with(['option' => 'value']); + + $mock->configure(['option' => 'value']); + } + + public function testProcess(): void + { + $mock = $this->createMock(ConfigurableProcessor::class); + $mock->expects($this->once()) + ->method('process') + ->with('input') + ->willReturn('output'); + + $this->assertSame('output', $mock->process('input')); + } +} diff --git a/tests/Processor/PipelineTest.php b/tests/Processor/PipelineTest.php new file mode 100644 index 0000000..0fa0e1c --- /dev/null +++ b/tests/Processor/PipelineTest.php @@ -0,0 +1,36 @@ +createMock(Pipeline::class); + $processor = $this->createMock(Processor::class); + + $mock->expects($this->once()) + ->method('addProcessor') + ->with($processor) + ->willReturnSelf(); + + $this->assertSame($mock, $mock->addProcessor($processor)); + } + + public function testProcess(): void + { + $mock = $this->createMock(Pipeline::class); + $mock->expects($this->once()) + ->method('process') + ->with('input') + ->willReturn('output'); + + $this->assertSame('output', $mock->process('input')); + } +} diff --git a/tests/Processor/ProcessorTest.php b/tests/Processor/ProcessorTest.php new file mode 100644 index 0000000..dcdb94a --- /dev/null +++ b/tests/Processor/ProcessorTest.php @@ -0,0 +1,22 @@ +createMock(Processor::class); + $mock->expects($this->once()) + ->method('process') + ->with('input') + ->willReturn('output'); + + $this->assertSame('output', $mock->process('input')); + } +}