WhoopsProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getRunner() 0 20 4
A needsDefault() 0 4 2
1
<?php
2
3
namespace Mosaic\Exceptions\Providers;
4
5
use Mosaic\Exceptions\Adapters\Whoops\Runner as Adapter;
6
use Mosaic\Exceptions\Runner;
7
use Whoops\Handler\PlainTextHandler;
8
use Whoops\Run;
9
10
class WhoopsProvider extends ExceptionHandlerProvider
11
{
12
    /**
13
     * @return Runner
14
     */
15 1
    public function getRunner() : Runner
16
    {
17 1
        $adapter = new Adapter(
18 1
            new Run
19
        );
20
21 1
        foreach ($this->handlers as $handler) {
22
            $adapter->addHandler($handler);
23
        }
24
25 1
        foreach ($this->formatters as $formatter) {
26
            $adapter->addFormatter($formatter);
27
        }
28
29 1
        if ($this->needsDefault()) {
30 1
            $adapter->addFormatter(new PlainTextHandler);
31
        }
32
33 1
        return $adapter;
34
    }
35
36
    /**
37
     * @return bool
38
     */
39 1
    private function needsDefault()
40
    {
41 1
        return count($this->handlers) < 1 && count($this->formatters) < 1;
42
    }
43
}
44