Skip to content

Commit fe4d5ad

Browse files
committed
Updated code to be compatible with php-etl/pipeline-contracts:0.5
1 parent c51837d commit fe4d5ad

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed

src/Console.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function extract(
3737

3838
$this->state->withStep((string) $step)
3939
->addMetric('read', $state->observeAccept())
40-
->addMetric('error', fn () => 0)
40+
->addMetric('error', $state->observeError())
4141
->addMetric('rejected', $state->observeReject())
4242
;
4343

src/MemoryState.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace Kiboko\Component\Runtime\Pipeline;
66

77
use Kiboko\Contract\Pipeline\StateInterface;
8+
use Kiboko\Contract\Pipeline\StepCodeInterface;
89

910
final class MemoryState implements StateInterface
1011
{
@@ -26,21 +27,21 @@ public function initialize(int $start = 0): void
2627
$this->decorated?->initialize($start);
2728
}
2829

29-
public function accept(int $step = 1): void
30+
public function accept(StepCodeInterface $step, int $count = 1): void
3031
{
31-
$this->metrics['accept'] += $step;
32+
$this->metrics['accept'] += $count;
3233
$this->decorated?->accept($step);
3334
}
3435

35-
public function reject(int $step = 1): void
36+
public function reject(StepCodeInterface $step, int $count = 1): void
3637
{
37-
$this->metrics['reject'] += $step;
38+
$this->metrics['reject'] += $count;
3839
$this->decorated?->reject($step);
3940
}
4041

41-
public function error(int $step = 1): void
42+
public function error(StepCodeInterface $step, int $count = 1): void
4243
{
43-
$this->metrics['error'] += $step;
44+
$this->metrics['error'] += $count;
4445
$this->decorated?->error($step);
4546
}
4647

@@ -49,6 +50,11 @@ public function observeAccept(): callable
4950
return fn () => $this->metrics['accept'];
5051
}
5152

53+
public function observeError(): callable
54+
{
55+
return fn () => $this->metrics['error'];
56+
}
57+
5258
public function observeReject(): callable
5359
{
5460
return fn () => $this->metrics['reject'];

src/Pipeline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
final class Pipeline
1212
{
13-
/** @var Step */
13+
/** @var list<Step> */
1414
private array $steps = [];
1515
private readonly ConsoleSectionOutput $section;
1616

src/Step/MemoryState.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public function observeAccept(): callable
4242
return fn () => $this->metrics['accept'];
4343
}
4444

45-
public function observeReject(): callable
45+
public function observeError(): callable
4646
{
47-
return fn () => $this->metrics['reject'];
47+
return fn () => $this->metrics['accept'];
4848
}
4949

50-
public function teardown(): void
50+
public function observeReject(): callable
5151
{
52-
$this->decorated?->teardown();
52+
return fn () => $this->metrics['reject'];
5353
}
5454
}

0 commit comments

Comments
 (0)