Clockwork   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 43
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 13 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cortex\Foundation\Http\Middleware;
6
7
use Closure;
8
use Exception;
9
use Illuminate\Foundation\Application;
10
11
class Clockwork
12
{
13
    /**
14
     * The Laravel Application.
15
     *
16
     * @var Application
17
     */
18
    protected $app;
19
20
    /**
21
     * Create a new Clockwork middleware instance.
22
     *
23
     * @param Application $app
24
     *
25
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
26
     */
27
    public function __construct(Application $app)
28
    {
29
        $this->app = $app;
30
    }
31
32
    /**
33
     * Handle an incoming request.
34
     *
35
     * @param \Illuminate\Http\Request $request
36
     * @param \Closure                 $next
37
     *
38
     * @return mixed
39
     */
40
    public function handle($request, Closure $next)
41
    {
42
        $this->app['config']->set('clockwork::config.middleware', true);
43
44
        try {
45
            $response = $next($request);
46
        } catch (Exception $e) {
47
            $this->app['Illuminate\Contracts\Debug\ExceptionHandler']->report($e);
48
            $response = $this->app['Illuminate\Contracts\Debug\ExceptionHandler']->render($request, $e);
49
        }
50
51
        return $this->app['clockwork.support']->process($request, $response);
52
    }
53
}
54