JsonErrorHandlerProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A initialize() 0 13 3
1
<?php
2
3
namespace Weew\HttpApp\ErrorHandler\Json;
4
5
use Weew\App\IApp;
6
use Weew\Container\IContainer;
7
use Weew\ErrorHandler\IErrorHandler;
8
use Weew\HttpApp\IHttpApp;
9
10
class JsonErrorHandlerProvider {
11
    /**
12
     * @param IApp $app
13
     * @param IErrorHandler $errorHandler
14
     * @param IContainer $container
15
     */
16
    public function initialize(
17
        IApp $app,
18
        IErrorHandler $errorHandler,
19
        IContainer $container
20
    ) {
21
        if ($app instanceof IHttpApp && $app->getDebug()) {
22
            $jsonErrorHandler = new JsonErrorHandler($app, $errorHandler);
23
            $jsonErrorHandler->enableErrorHandling();
24
            $jsonErrorHandler->enableExceptionHandling();
25
26
            $container->set(JsonErrorHandler::class, $jsonErrorHandler);
27
        }
28
    }
29
}
30