Total Complexity | 5 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
8 | class ContainerCleaner extends BaseCleaner |
||
9 | { |
||
10 | private $properties = [ |
||
11 | // Property => Initial value |
||
12 | 'reboundCallbacks' => [], |
||
13 | 'currentRoute' => [], // For Lumen: fixed wrong $request->route() |
||
14 | ]; |
||
15 | |||
16 | private $cleanProperties = [ |
||
17 | // Property => ReflectionObject |
||
18 | ]; |
||
19 | |||
20 | public function __construct(Container $currentApp, Container $snapshotApp) |
||
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() |
||
39 | } |
||
40 | } |
||
41 | } |