SessionCleaner   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
c 0
b 0
f 0
dl 0
loc 31
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A clean() 0 14 3
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace Hhxsv5\LaravelS\Illuminate\Cleaners;
4
5
6
use Illuminate\Container\Container;
0 ignored issues
show
Bug introduced by
The type Illuminate\Container\Container was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use Illuminate\Routing\Redirector;
0 ignored issues
show
Bug introduced by
The type Illuminate\Routing\Redirector was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Illuminate\Support\Facades\Facade;
0 ignored issues
show
Bug introduced by
The type Illuminate\Support\Facades\Facade was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
class SessionCleaner extends BaseCleaner
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class SessionCleaner
Loading history...
11
{
12
    private $drivers;
0 ignored issues
show
Coding Style introduced by
Private member variable "drivers" must be prefixed with an underscore
Loading history...
13
14
    public function __construct(Container $currentApp, Container $snapshotApp)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
15
    {
16
        parent::__construct($currentApp, $snapshotApp);
17
18
        if (!isset($this->currentApp['session'])) {
19
            return;
20
        }
21
        $ref = new \ReflectionObject($this->currentApp['session']);
22
        $this->drivers = $ref->getProperty('drivers');
23
        $this->drivers->setAccessible(true);
24
25
    }
26
27
    public function clean()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function clean()
Loading history...
28
    {
29
        if (!isset($this->currentApp['session'])) {
30
            return;
31
        }
32
33
        $this->drivers->setValue($this->currentApp['session'], []);
34
        $this->currentApp->forgetInstance('session.store');
35
        Facade::clearResolvedInstance('session.store');
36
37
        if (isset($this->currentApp['redirect'])) {
38
            /**@var Redirector $redirect */
0 ignored issues
show
Coding Style introduced by
The open comment tag must be the only content on the line
Loading history...
Coding Style introduced by
Missing short description in doc comment
Loading history...
Coding Style introduced by
The close comment tag must be the only content on the line
Loading history...
39
            $redirect = $this->currentApp['redirect'];
40
            $redirect->setSession($this->currentApp->make('session.store'));
41
        }
42
    }
43
}