ContainerCleaner   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A clean() 0 4 2
A __construct() 0 13 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
8
class ContainerCleaner extends BaseCleaner
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class ContainerCleaner
Loading history...
9
{
10
    private $properties = [
0 ignored issues
show
Coding Style introduced by
Private member variable "properties" must be prefixed with an underscore
Loading history...
11
        // Property => Initial value
12
        'reboundCallbacks' => [],
13
        'currentRoute'     => [], // For Lumen: fixed wrong $request->route()
14
    ];
15
16
    private $cleanProperties = [
0 ignored issues
show
Coding Style introduced by
Private member variable "cleanProperties" must be prefixed with an underscore
Loading history...
17
        // Property => ReflectionObject
18
    ];
19
20
    public function __construct(Container $currentApp, Container $snapshotApp)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
21
    {
22
        parent::__construct($currentApp, $snapshotApp);
23
        $currentReflection = new \ReflectionObject($this->currentApp);
24
        $defaultValues = $currentReflection->getDefaultProperties();
25
        foreach ($this->properties as $property => &$initValue) {
26
            if ($currentReflection->hasProperty($property)) {
27
                $this->cleanProperties[$property] = $currentReflection->getProperty($property);
28
                $this->cleanProperties[$property]->setAccessible(true);
29
                $initValue = $defaultValues[$property];
30
            }
31
        }
32
        unset($initValue);
33
    }
34
35
    public function clean()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function clean()
Loading history...
36
    {
37
        foreach ($this->cleanProperties as $property => $reflection) {
38
            $reflection->setValue($this->currentApp, $this->properties[$property]);
39
        }
40
    }
41
}