diff --git a/src/MemoryState.php b/src/MemoryState.php index 1c224ca..681ee9e 100644 --- a/src/MemoryState.php +++ b/src/MemoryState.php @@ -4,58 +4,10 @@ namespace Kiboko\Component\State; -use Kiboko\Contract\Pipeline\StateInterface; +trigger_deprecation('php-etl/console-state', '0.3', 'The "%s" class is deprecated, use "%s" instead.', 'Kiboko\\Component\\State\\MemoryState', 'Kiboko\\Component\\Runtime\\Pipeline\\Step\\MemoryState'); -final class MemoryState implements StateInterface -{ - private array $metrics = []; +/* + * @deprecated since Satellite 0.2, use Kiboko\Component\Runtime\Pipeline\Step\MemoryState instead. + */ +class_alias('Kiboko\\Component\\Runtime\\Pipeline\\Step\\MemoryState', 'Kiboko\\Component\\State\\MemoryState'); - public function __construct( - private readonly ?StateInterface $decorated = null, - ) { - } - - public function initialize(int $start = 0): void - { - $this->metrics = [ - 'accept' => 0, - 'reject' => 0, - 'error' => 0, - ]; - - $this->decorated?->initialize($start); - } - - public function accept(int $step = 1): void - { - $this->metrics['accept'] += $step; - $this->decorated?->accept($step); - } - - public function reject(int $step = 1): void - { - $this->metrics['reject'] += $step; - $this->decorated?->reject($step); - } - - public function error(int $step = 1): void - { - $this->metrics['error'] += $step; - $this->decorated?->error($step); - } - - public function observeAccept(): callable - { - return fn () => $this->metrics['accept']; - } - - public function observeReject(): callable - { - return fn () => $this->metrics['reject']; - } - - public function teardown(): void - { - $this->decorated?->teardown(); - } -} diff --git a/src/StateOutput/Pipeline.php b/src/StateOutput/Pipeline.php index db911eb..c4ae730 100644 --- a/src/StateOutput/Pipeline.php +++ b/src/StateOutput/Pipeline.php @@ -4,34 +4,9 @@ namespace Kiboko\Component\State\StateOutput; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Console\Output\ConsoleSectionOutput; +trigger_deprecation('php-etl/console-state', '0.3', 'The "%s" class is deprecated, use "%s" instead.', 'Kiboko\\Component\\State\\StateOutput\\Pipeline', \Kiboko\Component\Runtime\Pipeline\Pipeline::class); -final class Pipeline -{ - /** @var list */ - private array $steps = []; - private readonly ConsoleSectionOutput $section; - - public function __construct( - private readonly ConsoleOutput $output, - string $index, - string $label, - ) { - $this->section = $output->section(); - $this->section->writeln(''); - $this->section->writeln(sprintf(' % 2s. %-50s', $index, $label)); - } - - public function withStep(string $label): PipelineStep - { - return $this->steps[] = new PipelineStep($this->output, \count($this->steps) + 1, $label); - } - - public function update(): void - { - foreach ($this->steps as $step) { - $step->update(); - } - } -} +/* + * @deprecated since Satellite 0.2, use Kiboko\Component\Runtime\Pipeline\Pipeline instead. + */ +class_alias(\Kiboko\Component\Runtime\Pipeline\Pipeline::class, 'Kiboko\\Component\\State\\StateOutput\\Pipeline'); diff --git a/src/StateOutput/PipelineStep.php b/src/StateOutput/PipelineStep.php index afd6632..ad58afe 100644 --- a/src/StateOutput/PipelineStep.php +++ b/src/StateOutput/PipelineStep.php @@ -4,41 +4,9 @@ namespace Kiboko\Component\State\StateOutput; -use Symfony\Component\Console\Output\ConsoleOutput; -use Symfony\Component\Console\Output\ConsoleSectionOutput; +trigger_deprecation('php-etl/console-state', '0.3', 'The "%s" class is deprecated, use "%s" instead.', 'Kiboko\\Component\\State\\StateOutput\\Pipeline', \Kiboko\Component\Runtime\Pipeline\Step\Step::class); -final class PipelineStep -{ - /** @var array */ - private array $metrics = []; - private readonly ConsoleSectionOutput $section; - - public function __construct( - private readonly ConsoleOutput $output, - int $index, - string $label, - ) { - $this->section = $this->output->section(); - $this->section->writeln(sprintf(' % 2d. %-50s', $index, $label)); - $this->section->writeln(''); - } - - public function addMetric(string $label, callable $callback): self - { - $this->metrics[$label] = $callback; - - return $this; - } - - public function update(): void - { - $this->section->clear(1); - $this->section - ->writeln(' '.implode(', ', array_map( - fn (string $label, callable $callback) => sprintf('%s %d', $label, ($callback)()), - array_keys($this->metrics), - array_values($this->metrics), - ))) - ; - } -} +/* + * @deprecated since Satellite 0.2, use Kiboko\Component\Runtime\Pipeline\Step\Step instead. + */ +class_alias(\Kiboko\Component\Runtime\Pipeline\Step\Step::class, 'Kiboko\\Component\\State\\StateOutput\\Pipeline');