HandlerCompositeTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 7
c 1
b 0
f 0
dl 0
loc 15
ccs 2
cts 4
cp 0.5
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A includeMiddleware() 0 6 1
A catch() 0 5 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\Interfaces\ExceptionHandlerInterface;
9
use Lit\Nimo\Middlewares\NoopMiddleware;
10
use Psr\Http\Server\MiddlewareInterface;
11
use Psr\Http\Server\RequestHandlerInterface;
12
13
trait HandlerCompositeTrait
14
{
15 1
    public function includeMiddleware(MiddlewareInterface $middleware): MiddlewareIncluedHandler
16
    {
17
        /**
18
         * @var RequestHandlerInterface $this
19
         */
20 1
        return new MiddlewareIncluedHandler($this, $middleware);
21
    }
22
23
    public function catch(
24
        ExceptionHandlerInterface $catcher,
25
        string $catchClass = \Throwable::class
26
    ): MiddlewareIncluedHandler {
27
        return $this->includeMiddleware(NoopMiddleware::instance()->catch($catcher, $catchClass));
28
    }
29
}
30