WhoopsServiceProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 6
dl 0
loc 22
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 8 2
A subscribe() 0 10 2
1
<?php
2
/**
3
 * Whoops - php errors for cool kids
4
 * @author Filipe Dobreira <http://github.com/filp>
5
 */
6
7
namespace WhoopsSilex;
8
9
use Pimple\Container;
10
use Pimple\ServiceProviderInterface;
11
use Silex\Application;
12
use Silex\Api\EventListenerProviderInterface;
13
use Silex\ExceptionListenerWrapper;
14
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
15
use Symfony\Component\HttpKernel\KernelEvents;
16
use WhoopsPimple\WhoopsServiceProvider as PimpleWhoopsServiceProvider;
17
use WhoopsSilex\SilexApplicationHandler;
18
use WhoopsSilex\RequestHandler;
19
20
class WhoopsServiceProvider implements ServiceProviderInterface, EventListenerProviderInterface
21
{
22
    public function register(Container $container)
23
    {
24
        $container->register(new PimpleWhoopsServiceProvider);
25
        $container['whoops']->pushHandler(new RequestHandler($container));
26
        if ($container instanceof Application) {
27
            $container['whoops']->pushHandler(new SilexApplicationHandler($container));
28
        }
29
    }
30
31
    public function subscribe(Container $container, EventDispatcherInterface $dispatcher)
32
    {
33
        if ($container instanceof Application) {
34
            $dispatcher->addListener(
35
                KernelEvents::EXCEPTION,
36
                new ExceptionListenerWrapper($container, $container['whoops.exception_handler']),
37
                -1
38
            );
39
        }
40
    }
41
}
42