Passed
Push — master ( 0b73c6...7f4b2c )
by mcfog
02:23
created

HandlerTrait::catch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lit\Nimo\Traits;
6
7
use Lit\Nimo\Handlers\MiddlewareIncluedHandler;
8
use Lit\Nimo\Middlewares\NoopMiddleware;
9
use Psr\Http\Server\MiddlewareInterface;
10
use Psr\Http\Server\RequestHandlerInterface;
11
12
trait HandlerTrait
13
{
14 1
    public function includeMiddleware(MiddlewareInterface $middleware): RequestHandlerInterface
15
    {
16
        /**
17
         * @var RequestHandlerInterface $this
18
         */
19 1
        return new MiddlewareIncluedHandler($this, $middleware);
20
    }
21
22
    public function catch(callable $catcher, string $catchClass = \Throwable::class): RequestHandlerInterface
0 ignored issues
show
Coding Style introduced by
Possible parse error: non-abstract method defined as abstract
Loading history...
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
23
    {
24
        return $this->includeMiddleware(NoopMiddleware::instance()->catch($catcher, $catchClass));
25
    }
26
}
27