Skip to content

Commit 5bb273c

Browse files
authored
Update Pipeline.php
1 parent b087b62 commit 5bb273c

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

src/Pipeline.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,21 @@ final class Pipeline implements PipelineInterface
1515
{
1616
private Queue $queue;
1717
private RequestHandlerInterface $handler;
18+
19+
public function __clone()
20+
{
21+
$this->queue = clone $this->queue;
22+
$this->handler = clone $this->handler;
23+
}
1824

19-
/**
20-
* Pipeline constructor.
21-
* @param RequestHandlerInterface|null $fallbackHandler
22-
*/
2325
public function __construct(?RequestHandlerInterface $fallbackHandler = null)
2426
{
2527
$this->queue = new Queue();
2628
$this->handler = $fallbackHandler ?? new EmptyPipelineHandler();
2729
}
28-
29-
public function fallbackHandler(?RequestHandlerInterface $handler = null):? RequestHandlerInterface
30-
{
31-
return $handler != null ? $this->handler = $handler : $this->handler;
32-
}
33-
30+
3431
/**
35-
* @param MiddlewareInterface $middleware
36-
* @return Pipeline
32+
* @inheritDoc
3733
*/
3834
public function pipe(MiddlewareInterface $middleware): PipelineInterface
3935
{
@@ -42,18 +38,15 @@ public function pipe(MiddlewareInterface $middleware): PipelineInterface
4238
}
4339

4440
/**
45-
* @param ServerRequestInterface $request
46-
* @param RequestHandlerInterface $handler
47-
* @return ResponseInterface
41+
* @inheritDoc
4842
*/
4943
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
5044
{
5145
return (new Next($this->queue, $handler))->handle($request);
5246
}
5347

5448
/**
55-
* @param ServerRequestInterface $request
56-
* @return ResponseInterface
49+
* @inheritDoc
5750
*/
5851
public function handle(ServerRequestInterface $request): ResponseInterface
5952
{
@@ -76,4 +69,9 @@ public static function makeOf(iterable $middleware = [], ?RequestHandlerInterfac
7669

7770
return $pipeline;
7871
}
72+
73+
public function fallbackHandler(?RequestHandlerInterface $handler = null):? RequestHandlerInterface
74+
{
75+
return $handler != null ? $this->handler = $handler : $this->handler;
76+
}
7977
}

0 commit comments

Comments
 (0)