Completed
Branch master (9dff9d)
by Albert
05:30
created

RebindKernelContainer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 14 2
1
<?php
2
3
namespace SwooleTW\Http\Server\Resetters;
4
5
use SwooleTW\Http\Server\Sandbox;
6
use Illuminate\Contracts\Http\Kernel;
7
use Illuminate\Contracts\Container\Container;
8
use SwooleTW\Http\Server\Resetters\ResetterContract;
9
10
class RebindKernelContainer implements ResetterContract
11
{
12
    /**
13
     * "handle" function for resetting app.
14
     *
15
     * @param \Illuminate\Contracts\Container\Container $app
16
     * @param \SwooleTW\Http\Server\Sandbox $sandbox
17
     */
18
    public function handle(Container $app, Sandbox $sandbox)
19
    {
20
        if ($sandbox->isLaravel()) {
21
            $kernel = $app->make(Kernel::class);
22
23
            $closure = function () use ($app) {
24
                $this->app = $app;
0 ignored issues
show
Bug Best Practice introduced by
The property app does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
25
            };
26
27
            $resetKernel = $closure->bindTo($kernel, $kernel);
28
            $resetKernel();
29
        }
30
31
        return $app;
32
    }
33
}
34