Completed
Push — master ( c83b26...4d419a )
by Biao
04:28
created

AuthCleaner::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
c 0
b 0
f 0
nc 3
nop 2
dl 0
loc 14
rs 9.9666
1
<?php
2
3
namespace Hhxsv5\LaravelS\Illuminate\Cleaners;
4
5
6
use Illuminate\Container\Container;
7
use Illuminate\Support\Facades\Facade;
8
9
class AuthCleaner extends BaseCleaner
10
{
11
    private $guards;
12
13
    public function __construct(Container $currentApp, Container $snapshotApp)
14
    {
15
        parent::__construct($currentApp, $snapshotApp);
16
17
        if (!isset($this->currentApp['auth'])) {
18
            return;
19
        }
20
        $ref = new \ReflectionObject($this->currentApp['auth']);
21
        if ($ref->hasProperty('guards')) {
22
            $this->guards = $ref->getProperty('guards');
23
        } else {
24
            $this->guards = $ref->getProperty('drivers');
25
        }
26
        $this->guards->setAccessible(true);
27
    }
28
29
    public function clean()
30
    {
31
        if (!$this->guards) {
32
            return;
33
        }
34
        $this->guards->setValue($this->currentApp['auth'], []);
35
        $this->currentApp->forgetInstance('auth.driver');
36
        Facade::clearResolvedInstance('auth.driver');
37
    }
38
}