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

HandlerTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 13
ccs 2
cts 4
cp 0.5
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A includeMiddleware() 0 6 1
A catch() 0 3 1
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