GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

StandardDebugBar   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 14

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 2
Metric Value
dl 0
loc 59
ccs 0
cts 33
cp 0
rs 10
c 3
b 0
f 2
wmc 7
lcom 1
cbo 14

4 Methods

Rating   Name   Duplication   Size   Complexity  
A doBoot() 0 20 3
A addQueryCollector() 0 9 1
A populateQueryCollector() 0 10 2
A initDatabaseConnection() 0 10 1
1
<?php
2
3
namespace Nip\DebugBar;
4
5
use DebugBar\DataCollector\ExceptionsCollector;
6
use DebugBar\DataCollector\MemoryCollector;
7
use DebugBar\DataCollector\MessagesCollector;
8
use DebugBar\DataCollector\PhpInfoCollector;
9
use DebugBar\DataCollector\RequestDataCollector;
10
use DebugBar\DataCollector\TimeDataCollector;
11
use Monolog\Logger as Monolog;
12
use Nip\Database\Connections\Connection;
13
use Nip\Database\DatabaseManager;
14
use Nip\DebugBar\DataCollector\QueryCollector;
15
use Nip\DebugBar\DataCollector\RouteCollector;
16
use Nip\Profiler\Adapters\DebugBar as ProfilerDebugBar;
17
18
/**
19
 * Class StandardDebugBar
20
 * @package Nip\DebugBar
21
 */
22
class StandardDebugBar extends DebugBar
23
{
24
25
    public function doBoot()
26
    {
27
        $this->addCollector(new PhpInfoCollector());
28
        $this->addCollector(new MessagesCollector());
29
        $this->addCollector(new RequestDataCollector());
30
        $this->addCollector(new TimeDataCollector());
31
        $this->addCollector(new MemoryCollector());
32
        $this->addCollector(new RouteCollector());
33
34
        if (app()->has('db')) {
35
            $this->addQueryCollector();
36
        }
37
38
        if (app()->has(Monolog::class)) {
39
            $monolog = app(Monolog::class);
40
            $this->addMonolog($monolog);
41
        } else {
42
            $this->addCollector(new ExceptionsCollector());
43
        }
44
    }
45
46
    public function addQueryCollector()
47
    {
48
        $this->addCollector(new QueryCollector());
49
50
        $databaseManager = app('db');
51
        $databaseManager->connection();
52
53
        $this->populateQueryCollector();
54
    }
55
56
    public function populateQueryCollector()
57
    {
58
        /** @var DatabaseManager $databaseManager */
59
        $databaseManager = app('db');
60
        $connections = $databaseManager->getConnections();
61
62
        foreach ($connections as $connection) {
63
            $this->initDatabaseConnection($connection);
64
        }
65
    }
66
67
    /**
68
     * @param Connection $connection
69
     */
70
    public function initDatabaseConnection($connection)
71
    {
72
        $profiler = $connection->getAdapter()->newProfiler()->setEnabled(true);
73
        $writer = $profiler->newWriter('DebugBar');
74
75
        /** @var ProfilerDebugBar $writer */
76
        $writer->setCollector($this->getCollector('queries'));
0 ignored issues
show
Compatibility introduced by
$this->getCollector('queries') of type object<DebugBar\DataColl...DataCollectorInterface> is not a sub-type of object<Nip\DebugBar\DataCollector\QueryCollector>. It seems like you assume a concrete implementation of the interface DebugBar\DataCollector\DataCollectorInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
77
        $profiler->addWriter($writer);
78
        $connection->getAdapter()->setProfiler($profiler);
79
    }
80
}
81