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

RebindViewContainer   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 1

1 Method

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