RebindViewContainer::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 13
rs 10
1
<?php
2
3
namespace SwooleTW\Http\Server\Resetters;
4
5
use Illuminate\Contracts\Container\Container;
6
use SwooleTW\Http\Server\Sandbox;
7
8
class RebindViewContainer implements ResetterContract
9
{
10
    /**
11
     * @var Container
12
     */
13
    protected $container;
14
15
    /**
16
     * @var array
17
     */
18
    protected $shared;
19
20
    /**
21
     * "handle" function for resetting app.
22
     *
23
     * @param \Illuminate\Contracts\Container\Container $app
24
     * @param \SwooleTW\Http\Server\Sandbox $sandbox
25
     *
26
     * @return \Illuminate\Contracts\Container\Container
27
     */
28
    public function handle(Container $app, Sandbox $sandbox)
29
    {
30
        $view = $app->make('view');
31
32
        $closure = function () use ($app) {
33
            $this->container = $app;
34
            $this->shared['app'] = $app;
35
        };
36
37
        $resetView = $closure->bindTo($view, $view);
38
        $resetView();
39
40
        return $app;
41
    }
42
}
43