1 | <?php |
||
7 | class Pipeline implements PipelineInterface |
||
8 | { |
||
9 | /** |
||
10 | * @var callable[] |
||
11 | */ |
||
12 | protected $stages = []; |
||
13 | |||
14 | /** |
||
15 | * @var ProcessorInterface |
||
16 | */ |
||
17 | private $processor; |
||
18 | |||
19 | /** |
||
20 | * Constructor. |
||
21 | * |
||
22 | * @param callable[] $stages |
||
23 | * @param ProcessorInterface $processor |
||
24 | * |
||
25 | * @throws InvalidArgumentException |
||
26 | */ |
||
27 | 20 | public function __construct(array $stages = [], ProcessorInterface $processor = null) |
|
38 | |||
39 | /** |
||
40 | * @inheritdoc |
||
41 | */ |
||
42 | 10 | public function pipe(callable $stage) |
|
49 | |||
50 | /** |
||
51 | * Process the payload. |
||
52 | * |
||
53 | * @param $payload |
||
54 | * |
||
55 | * @return mixed |
||
56 | */ |
||
57 | 10 | public function process($payload) |
|
61 | |||
62 | /** |
||
63 | * Fork the pipeline |
||
64 | * |
||
65 | * @param callable|null $resolver |
||
66 | * |
||
67 | * @return Fork |
||
68 | */ |
||
69 | 2 | public function fork(callable $resolver = null) |
|
76 | |||
77 | /** |
||
78 | * @inheritdoc |
||
79 | */ |
||
80 | 4 | public function __invoke($payload) |
|
84 | } |
||
85 |