Passed
Push — master ( 400934...9d586b )
by Anton
02:32
created

LogCollectorBootloader   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 8
c 1
b 0
f 0
dl 0
loc 25
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A boot() 0 9 1
1
<?php
2
3
/**
4
 * Spiral Framework.
5
 *
6
 * @license   MIT
7
 * @author    Anton Titov (Wolfy-J)
8
 */
9
10
declare(strict_types=1);
11
12
namespace Spiral\Bootloader\Debug;
13
14
use Spiral\Boot\Bootloader\Bootloader;
15
use Spiral\Boot\FinalizerInterface;
16
use Spiral\Bootloader\DebugBootloader;
17
use Spiral\Debug\StateCollector\LogCollector;
18
use Spiral\Logger\ListenerRegistryInterface;
0 ignored issues
show
Bug introduced by
The type Spiral\Logger\ListenerRegistryInterface 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...
19
20
/**
21
 * Copies all application logs into debug state.
22
 */
23
final class LogCollectorBootloader extends Bootloader
24
{
25
    protected const DEPENDENCIES = [
26
        DebugBootloader::class
27
    ];
28
29
    protected const SINGLETONS = [
30
        LogCollector::class => LogCollector::class
31
    ];
32
33
    /**
34
     * @param LogCollector              $logCollector
35
     * @param DebugBootloader           $debug
36
     * @param ListenerRegistryInterface $listenerRegistry
37
     * @param FinalizerInterface        $finalizer
38
     */
39
    public function boot(
40
        LogCollector $logCollector,
41
        DebugBootloader $debug,
42
        ListenerRegistryInterface $listenerRegistry,
43
        FinalizerInterface $finalizer
44
    ): void {
45
        $debug->addStateCollector($logCollector);
46
        $listenerRegistry->addListener($logCollector);
47
        $finalizer->addFinalizer([$logCollector, 'reset']);
48
    }
49
}
50