Completed
Push — master ( a9f19e...00e6c7 )
by Dominik
02:06
created

AdvancedErrorHandlerProvider   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 32
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B register() 0 26 1
1
<?php
2
3
namespace Chubbyphp\ErrorHandler\Slim;
4
5
use Chubbyphp\ErrorHandler\ContentTypeResolver;
6
use Negotiation\Negotiator;
7
use Pimple\Container;
8
use Pimple\ServiceProviderInterface;
9
10
final class AdvancedErrorHandlerProvider implements ServiceProviderInterface
11
{
12
    /**
13
     * @param Container $container
14
     */
15
    public function register(Container $container)
16
    {
17
        $container['errorHandler.acceptNegation'] = function () use ($container) {
18
            return new Negotiator();
19
        };
20
21
        $container['errorHandler.contentTypeResolver'] = function () use ($container) {
22
            return new ContentTypeResolver($container['errorHandler.acceptNegation']);
23
        };
24
25
        $container['errorHandler.defaultProvider'] = function () use ($container) {
26
            throw new \RuntimeException('Please configure your default provider for error handler!');
27
        };
28
29
        $container['errorHandler.providers'] = function () use ($container) {
30
            return [];
31
        };
32
33
        $container['errorHandler'] = function () use ($container) {
34
            return new AdvancedErrorHandler(
35
                $container['errorHandler.contentTypeResolver'],
36
                $container['errorHandler.defaultProvider'],
37
                $container['errorHandler.providers']
38
            );
39
        };
40
    }
41
}
42