DebugServiceProvider   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 42
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A provides() 0 4 1
A register() 0 5 1
A registerDebug() 0 6 1
A registerErrorHandler() 0 9 1
A boot() 0 4 1
1
<?php
2
3
namespace Nip\Debug;
4
5
use Nip\Container\ServiceProviders\Providers\AbstractSignatureServiceProvider;
6
use Nip\Container\ServiceProviders\Providers\BootableServiceProviderInterface;
7
use Nip\Debug\ErrorHandler;
8
use Psr\Log\LoggerInterface;
9
use Symfony\Component\ErrorHandler\BufferingLogger;
10
11
/**
12
 * Class LoggerServiceProvider
13
 * @package Nip\Logger
14
 */
15
class DebugServiceProvider extends AbstractSignatureServiceProvider implements BootableServiceProviderInterface
16
{
17
18
    /**
19
     * @inheritdoc
20
     */
21
    public function provides()
22
    {
23
        return ['error-handler', ErrorHandler::class, \Nip\Debug\ErrorHandler::class];
24
    }
25
26
    /**
27
     * @inheritdoc
28
     */
29
    public function register()
30
    {
31
        $this->registerDebug();
32
        $this->registerErrorHandler();
33
    }
34
35
    public function registerDebug()
36
    {
37
        $this->getContainer()->share('debug', function () {
38
            return new Debug();
39
        });
40
    }
41
42
    public function registerErrorHandler()
43
    {
44
        $this->getContainer()->share('error-handler', function () {
45
            return ErrorHandler::register(null, false);
46
        });
47
48
        $this->getContainer()->alias('error-handler', ErrorHandler::class);
49
        $this->getContainer()->alias('error-handler', \Nip\Debug\ErrorHandler::class);
50
    }
51
52
    public function boot()
53
    {
54
        ErrorHandler::register($this->getContainer()->get(ErrorHandler::class), true);
55
    }
56
}
57