Passed
Push — master ( b6a195...1e79f7 )
by mcfog
03:21
created

HandlerCompositeTrait::includeMiddleware()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 6
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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 HandlerCompositeTrait
13
{
14 1
    public function includeMiddleware(MiddlewareInterface $middleware): MiddlewareIncluedHandler
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): MiddlewareIncluedHandler
23
    {
24
        return $this->includeMiddleware(NoopMiddleware::instance()->catch($catcher, $catchClass));
25
    }
26
}
27