Passed
Push — master ( 47470a...ae4103 )
by Biao
04:05 queued 10s
created

ContainerCleaner::clean()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 2
c 1
b 1
f 0
nc 2
nop 0
dl 0
loc 4
rs 10
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
    ];
14
15
    private $cleanProperties = [
0 ignored issues
show
Coding Style introduced by
Private member variable "cleanProperties" must be prefixed with an underscore
Loading history...
16
        // Property => ReflectionObject
17
    ];
18
19
    public function __construct(Container $currentApp, Container $snapshotApp)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
20
    {
21
        parent::__construct($currentApp, $snapshotApp);
22
        $currentReflection = new \ReflectionObject($this->currentApp);
23
        $defaultValues = $currentReflection->getDefaultProperties();
24
        foreach ($this->properties as $property => &$initValue) {
25
            if ($currentReflection->hasProperty($property)) {
26
                $this->cleanProperties[$property] = $currentReflection->getProperty($property);
27
                $this->cleanProperties[$property]->setAccessible(true);
28
                $initValue = $defaultValues[$property];
29
            }
30
        }
31
        unset($initValue);
32
    }
33
34
    public function clean()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function clean()
Loading history...
35
    {
36
        foreach ($this->cleanProperties as $property => $reflection) {
37
            $reflection->setValue($this->currentApp, $this->properties[$property]);
38
        }
39
    }
40
}