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: README.md
+58-11Lines changed: 58 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -1,23 +1,21 @@
1
-
## Introduction:
1
+
## Introduction
2
2
3
3
Pipeline follows the Chain of Responsibility Design Pattern to handle the given subject/request using pipes.
4
4
5
-
## Documentation
6
-
7
-
### Installation (via Composer)
5
+
## Installation (via Composer)
8
6
9
7
Install library using composer command:
10
8
```sh
11
9
$ composer require thewebsolver/pipeline
12
10
```
13
11
14
-
###Usage
12
+
## Usage
15
13
16
-
The main responsibility of the Pipeline class is to pass given subject to all registered pipes and return back the transformed value. The pipeline chain can be initialised following builder pattern as follows:
14
+
The main responsibility of the Pipeline class is to pass given subject to all registered pipes and return back the transformed value. The pipeline chain can be initialized following builder pattern as follows:
17
15
- Initialize the pipeline (`new Pipeline()`).
18
16
- Pass subject to the pipeline using `Pipeline::send()` method.
19
17
- Provide a single handler using `Pipeline::pipe()` method or if multiple pipes (_which obviously should be the case, otherwise what is the intent of using Pipeline anyway_), use `Pipeline::through()` method.
20
-
> NOTE: `Pipeline::through()` is the main method to provide pipes. If pipes are provided using `Pipeline::pipe()` method and then required pipes are provided using `Pipeline::through()` method, pipes provided using `Pipeline::pipe()` will be defered. Meaning subject will pass through pipes provided using `Pipeline::through()` and then the transformed subject is pass through other pipes provided using `Pipeline::pipe()`.
18
+
> NOTE: `Pipeline::through()` is the main method to provide pipes. If pipes are provided using `Pipeline::pipe()` method and then required pipes are provided using `Pipeline::through()` method, pipes provided using `Pipeline::pipe()` will be deferred. Meaning subject will pass through pipes provided using `Pipeline::through()` and then the transformed subject is pass through other pipes provided using `Pipeline::pipe()`.
21
19
22
20
> In summary, `Pipeline::pipe()` method's intent is to append additional pipes to the pipeline after required pipes are provided using `Pipeline::through()` method.
23
21
@@ -29,7 +27,7 @@ There are two methods that may be required depending on how subject is being han
29
27
-`Pipeline::use()` method provides additional data to each pipe.
30
28
-`Pipeline::sealWith()` method provides prevention mechanism form script interruption if any pipe throws an exception.
31
29
32
-
####Basic Usage
30
+
### Basic Usage
33
31
```php
34
32
use TheWebSolver\Codegarage\Lib\Pipeline;
35
33
@@ -43,15 +41,15 @@ class MakeTextUpperCase implements PipeInterface {
The `TheWebSolver\Codegarage\Lib\PipelineBridge` seamlessly handles middlewares coming to the Request Handler, piping through the pipeline and getting the response back.
96
+
97
+
```php
98
+
use Closure;
99
+
use Psr\Http\Message\ResponseInterface;
100
+
use Psr\Http\Server\MiddlewareInterface;
101
+
use Psr\Http\Server\RequestHandlerInterface;
102
+
use Psr\Http\Message\ServerRequestInterface;
103
+
use TheWebSolver\Codegarage\Lib\PipelineBridge;
104
+
105
+
class RequestHandler implements RequestHandlerInterface {
106
+
/** @var array<Closure|MiddlewareInterface> */
107
+
protected array $middlewares;
108
+
109
+
public function addMiddleware(Closure|MiddlewareInterface $middleware) {
0 commit comments