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

WhoopsConfiguration::prepareJsonHandler()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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