Passed
Push — main ( 6f03e1...597168 )
by Thierry
13:43
created

JaxonCallbacks::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 12
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace App\Http\Middleware;
4
5
use App\Ajax\CallableClass;
6
use Illuminate\Http\RedirectResponse;
7
use Illuminate\Http\Request;
8
use Illuminate\Http\Response;
9
use Jaxon\Laravel\Jaxon;
10
use Closure;
11
12
use function app;
13
14
class JaxonCallbacks
15
{
16
    /**
17
     * Handle an incoming request.
18
     *
19
     * @param  Request  $request
20
     * @param  Closure(Request): (Response|RedirectResponse)  $next
21
     *
22
     * @return Response|RedirectResponse
23
     */
24
    public function handle(Request $request, Closure $next)
25
    {
26
        /** @var Jaxon */
27
        $jaxon = app()->make(Jaxon::class);
28
        $jaxon->callback()->init(function(CallableClass $callable) use($jaxon) {
29
            // Jaxon init
30
            $dialog = $jaxon->ajaxResponse()->dialog;
0 ignored issues
show
Bug introduced by
Accessing dialog on the interface Jaxon\Response\ResponseInterface suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
31
            $callable->dialog = $dialog;
32
            $callable->notify = $dialog;
33
        });
34
35
        return $next($request);
36
    }
37
}
38