SuppressionMiddleware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 6 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Middleware;
5
6
use Psr\Http\Message\ServerRequestInterface;
7
use Shoot\Shoot\MiddlewareInterface;
8
use Shoot\Shoot\SuppressedException;
9
use Shoot\Shoot\View;
10
11
/**
12
 * Suppresses exceptions thrown from within the optional tag. It's recommended to add this as the last middleware.
13
 */
14
final class SuppressionMiddleware implements MiddlewareInterface
15
{
16
    /**
17
     * Process the view within the context of the current HTTP request, either before or after calling the next
18
     * middleware. Returns the processed view.
19
     *
20
     * @param View                   $view
21
     * @param ServerRequestInterface $request
22
     * @param callable               $next
23
     *
24
     * @return View
25
     */
26 5
    public function process(View $view, ServerRequestInterface $request, callable $next): View
27
    {
28
        try {
29 5
            return $next($view);
30 4
        } catch (SuppressedException $exception) {
31 2
            return $view->withSuppressedException($exception->getPrevious());
32
        }
33
    }
34
}
35