Completed
Push — master ( 4234d3...b896a1 )
by Biao
04:10
created

LaravelAdminCleaner::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Hhxsv5\LaravelS\Illuminate\Cleaners;
4
5
use Illuminate\Container\Container;
6
use Illuminate\Support\Facades\Facade;
7
8
class LaravelAdminCleaner extends BaseCleaner
9
{
10
    const   ADMIN_CLASS = 'Encore\Admin\Admin';
11
    private   $reflection;
12
    protected $properties = [
13
        'deferredScript' => [],
14
        'script'         => [],
15
        'style'          => [],
16
        'css'            => [],
17
        'js'             => [],
18
        'html'           => [],
19
        'headerJs'       => [],
20
        'manifestData'   => [],
21
        'extensions'     => [],
22
        'menu'           => [],
23
        'minifyIgnores'  => [],
24
    ];
25
26
    public function __construct(Container $currentApp, Container $snapshotApp)
27
    {
28
        parent::__construct($currentApp, $snapshotApp);
29
        $this->reflection = new \ReflectionClass(self::ADMIN_CLASS);
30
    }
31
32
    public function clean()
33
    {
34
        foreach ($this->properties as $name => $value) {
35
            if (property_exists(self::ADMIN_CLASS, $name)) {
36
                $this->reflection->setStaticPropertyValue($name, $value);
37
            }
38
        }
39
        $this->currentApp->forgetInstance(self::ADMIN_CLASS);
40
        Facade::clearResolvedInstance(self::ADMIN_CLASS);
41
    }
42
}