Completed
Pull Request — master (#1)
by Woody
27:07 queued 01:07
created

WhoopsConfiguration   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%
Metric Value
wmc 4
lcom 0
cbo 4
dl 0
loc 45
ccs 16
cts 16
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A apply() 0 6 1
A prepareWhoops() 0 7 1
A prepareJsonHandler() 0 4 1
A preparePlainTextHandler() 0 4 1
1
<?php
2
3
namespace Equip\Configuration;
4
5
use Auryn\Injector;
6
use Whoops\Run as Whoops;
7
use Whoops\Handler\JsonResponseHandler;
8
use Whoops\Handler\PlainTextHandler;
9
10
class WhoopsConfiguration implements ConfigurationInterface
11
{
12
    /**
13
     * @inheritDoc
14
     */
15 12
    public function apply(Injector $injector)
16
    {
17 12
        $injector->prepare(Whoops::class, [$this, 'prepareWhoops']);
18 12
        $injector->prepare(JsonResponseHandler::class, [$this, 'prepareJsonHandler']);
19 12
        $injector->prepare(PlainTextHandler::class, [$this, 'preparePlainTextHandler']);
20 12
    }
21
22
    /**
23
     * @param Whoops $whoops
24
     *
25
     * @return void
26
     */
27 12
    public function prepareWhoops(Whoops $whoops)
28
    {
29 12
        set_error_handler([$whoops, Whoops::ERROR_HANDLER]);
30
31 12
        $whoops->writeToOutput(false);
32 12
        $whoops->allowQuit(false);
33 12
    }
34
35
    /**
36
     * @param JsonResponseHandler $handler
37
     *
38
     * @return void
39
     */
40 5
    public function prepareJsonHandler(JsonResponseHandler $handler)
41
    {
42 5
        $handler->addTraceToOutput(true);
43 5
    }
44
45
    /**
46
     * @param PlainTextHandler $handler
47
     *
48
     * @return void
49
     */
50 1
    public function preparePlainTextHandler(PlainTextHandler $handler)
51
    {
52 1
        $handler->outputOnlyIfCommandLine(false);
53 1
    }
54
}
55