MiddlewarePipe::pipe()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Furious\Psr15;
6
7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Psr\Http\Server\MiddlewareInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
use SplQueue;
12
13
final class MiddlewarePipe
14
    implements MiddlewareInterface,
15
        RequestHandlerInterface,
16
        PipeInterface
17
{
18
    private ?SplQueue $pipeline;
19
20
    public function __construct()
21
    {
22
        $this->pipeline = new SplQueue();
23
    }
24
25
    public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
26
    {
27
        return (new Next($this->pipeline, $handler))->handle($request);
28
    }
29
30
    public function handle(ServerRequestInterface $request): ResponseInterface
31
    {
32
        return $this->process($request, new EmptyPipelineHandler);
33
    }
34
35
    public function pipe(MiddlewareInterface $middleware): void
36
    {
37
        $this->pipeline->enqueue($middleware);
0 ignored issues
show
Bug introduced by
The method enqueue() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        $this->pipeline->/** @scrutinizer ignore-call */ 
38
                         enqueue($middleware);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
    }
39
}