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

LaravelAdminCleaner   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 4
Metric Value
eloc 22
c 5
b 0
f 4
dl 0
loc 33
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A clean() 0 9 3
A __construct() 0 4 1
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
}