You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: changelog.md
+8-4Lines changed: 8 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,14 +2,18 @@
2
2
3
3
## 4.0.0 - 2025-08-18
4
4
5
+
### Added
6
+
7
+
*`InterruptipleTapProcessor`, which implements both `InterruptipleProcessor` and `TapProcessor`
8
+
* Added generic typing information across the package
9
+
5
10
### Changed
6
11
7
12
***Minimum PHP version is now 8.3**
8
-
*Removed Orchestra Testbench in favor of PestPHP
13
+
*Test framework is now Pest
9
14
* Updated `nunomaduro/collision` to ^8.0
10
-
* Added generic typing information across the package
11
-
* Updated tests to be a bit more exhaustive
12
-
* Adds an `InterruptipleTapProcessor` that implements both `InterruptipleProcessor` and `TapProcessor`, with the exception that before and after callbacks are optional. I realise this means `InterruptipleProcessor` can be made redundant, but the idea is to simplify this package drastically in v5 (likely to use a single processor that does it all).
15
+
* Tests are now a bit more exhaustive
16
+
*`TapProcessor` now requires at least one callback when instantiated.
Built atop [League’s excellent package](https://github.com/thephpleague/pipeline), `Rockett\Pipeline` provides an implementation of the [pipeline pattern](https://en.wikipedia.org/wiki/Pipeline_(software)).
8
+
Built atop [League's excellent package](https://github.com/thephpleague/pipeline), `Rockett\Pipeline` provides an implementation of the [pipeline pattern](https://en.wikipedia.org/wiki/Pipeline_(software)) with additional processors for **conditional interruption** and **stage tapping**.
9
+
10
+
## Requirements
11
+
12
+
- PHP 8.3+
13
+
14
+
## Installation
15
+
16
+
```bash
17
+
composer require rockett/pipeline
18
+
```
19
+
20
+
## Quick Start
21
+
22
+
```php
23
+
use Rockett\Pipeline\Pipeline;
24
+
25
+
$pipeline = (new Pipeline)
26
+
->pipe(fn($x) => $x * 2)
27
+
->pipe(fn($x) => $x + 1);
28
+
29
+
echo $pipeline->process(10); // Outputs: 21
30
+
```
31
+
32
+
## Table of Contents
33
+
34
+
-[Pipeline Pattern](#pipeline-pattern)
35
+
-[Immutability](#immutability)
36
+
-[Usage](#usage)
37
+
-[Class-based stages](#class-based-stages)
38
+
-[Re-usability](#re-usability)
39
+
-[Pipeline Builders](#pipeline-builders)
40
+
-[Processors](#processors)
41
+
-[Handling Exceptions](#handling-exceptions)
11
42
12
43
## Pipeline Pattern
13
44
@@ -37,7 +68,7 @@ Pipelines are implemented as immutable stage-chains, contracted by the `Pipeline
37
68
38
69
## Usage
39
70
40
-
Operations in a pipeline (stages) can accept anything from the pipeline that satisfies the `callable` type-hint. So closures and anything that’s invokable will work.
71
+
Operations in a pipeline (stages) can accept anything from the pipeline that satisfies the `callable` type-hint. So closures and anything that's invokable will work.
41
72
42
73
```php
43
74
$pipeline = (new Pipeline)->pipe(static function ($traveler) {
When stages are piped through a pipeline, they are done so using a processor, which is responsible for iterating through each stage and piping it into the owning pipeline. There are three available processors:
154
+
**This is where Rockett\Pipeline extends League's package** – when stages are piped through a pipeline, they are done so using a processor, which is responsible for iterating through each stage and piping it into the owning pipeline. There are four available processors:
124
155
125
156
*`FingersCrossedProcessor` (this is the default)
126
-
*`InterruptibleProcessor`
127
-
*`TapProcessor`
157
+
*`InterruptibleProcessor` – Exit pipelines early based on conditions
158
+
*`TapProcessor` – Execute callbacks before/after each stage (requires at least one callback)
159
+
*`InterruptibleTapProcessor` – Combines both interruption and tapping (requires at least one tap callback)
128
160
129
-
It goes without saying that the default processor only iterates and pipes stages. It does nothing else, and there is no way to exit the pipeline without throwing an exception.
161
+
The default processor only iterates and pipes stages. It does nothing else, and there is no way to exit the pipeline without throwing an exception.
130
162
131
163
### Exiting pipelines early
132
164
133
-
The `InterruptibleProcessor`, on the other hand, provides a mechanism that allows you to exit the pipeline early, if so required. This is done by way of a `callable` that is invoked at every stage as a condition to continuing the pipeline:
165
+
The `InterruptibleProcessor` provides a mechanism that allows you to exit the pipeline early, if so required. This is done by way of a `callable` that is invoked at every stage as a condition to continuing the pipeline:
134
166
135
167
```php
136
168
use Rockett\Pipeline\Processors\InterruptibleProcessor;
In this example, the callable passed to the processor will check to see if something isn’t right and, if so, it will return `true`, causing the processor exit the pipeline and return the traveler as the output.
182
+
In this example, the callable will check if the traveler has an error and, if so, it will return `true`, causing the processor to exit the pipeline early and return the current traveler as the output.
151
183
152
-
You can also use the `continueUnless` helper to instantiate the interruptible processor:
Using the `TapProcessor`, you can invoke an action before and/or after a stage is piped through a pipeline. This can be useful if you would like to handle common side-effects outside of each stage, such as logging or broadcasting.
171
-
172
-
The processor takes two callables:
200
+
Using the `TapProcessor`, you can invoke an action before and/or after a stage is piped through a pipeline. This is useful for cross-cutting concerns like logging, metrics, or debugging.
173
201
174
202
```php
175
203
use Rockett\Pipeline\Processors\TapProcessor;
176
204
177
-
// Define and instantiate a $logger and a $broadcaster …
178
-
179
205
$processor = new TapProcessor(
180
-
// $beforeEach, called before a stage is piped
181
-
static fn ($traveler) => $logger->info('Traveller passing through pipeline:', $traveler->toArray()),
182
-
183
-
// $afterEach, called after a stage is piped and the output captured
0 commit comments