WhoopsConfiguration::preparePlainTextHandler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 3
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Equip\Configuration;
4
5
use Auryn\Injector;
6
use Whoops\Handler\JsonResponseHandler;
7
use Whoops\Handler\PlainTextHandler;
8
use Whoops\Run as Whoops;
9
10
class WhoopsConfiguration implements ConfigurationInterface
11
{
12
    use EnvTrait;
13
14
    /**
15
     * @inheritDoc
16
     */
17 13
    public function apply(Injector $injector)
18
    {
19 13
        $injector->prepare(Whoops::class, [$this, 'prepareWhoops']);
20 13
        $injector->prepare(JsonResponseHandler::class, [$this, 'prepareJsonHandler']);
21 13
        $injector->prepare(PlainTextHandler::class, [$this, 'preparePlainTextHandler']);
22 13
    }
23
24
    /**
25
     * @param Whoops $whoops
26
     *
27
     * @return void
28
     */
29 13
    public function prepareWhoops(Whoops $whoops)
30
    {
31 13
        if($this->env->getValue('DEBUG_STACKTRACE', false) == true) {
32 13
            set_error_handler([$whoops, Whoops::ERROR_HANDLER]);
33 13
        }
34
35 13
        $whoops->writeToOutput(false);
36 13
        $whoops->allowQuit(false);
37 13
    }
38
39
    /**
40
     * @param JsonResponseHandler $handler
41
     *
42
     * @return void
43
     */
44
    public function prepareJsonHandler(JsonResponseHandler $handler)
45
    {
46
        $handler->addTraceToOutput(true);
47
    }
48
49
    /**
50
     * @param PlainTextHandler $handler
51
     *
52
     * @return void
53
     */
54
    public function preparePlainTextHandler(PlainTextHandler $handler)
55
    {
56
        $handler->addTraceToOutput(true);
57
    }
58
}
59