Completed
Push — master ( 473611...d8e3ee )
by Patrick
04:55
created

Component::resolveBooboo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1
Metric Value
dl 0
loc 6
ccs 2
cts 2
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Mosaic\Exceptions;
4
5
use Mosaic\Common\Components\AbstractComponent;
6
use Mosaic\Exceptions\Providers\BoobooProvider;
7
use Mosaic\Exceptions\Providers\WhoopsProvider;
8
use Whoops\Handler\CallbackHandler;
9
10
/**
11
 * @method static $this whoops()
12
 * @method static $this booboo()
13
 */
14
final class Component extends AbstractComponent
15
{
16
    /**
17
     * @var array
18
     */
19
    protected $handlers = [];
20
21
    /**
22
     * @var array
23
     */
24
    protected $formatters = [];
25
26
    /**
27
     * @return array
28
     */
29 6
    public function resolveWhoops() : array
30
    {
31 6
        foreach ($this->formatters as $key => $formatter) {
32 3
            if (is_callable($formatter)) {
33 3
                $this->formatters[$key] = new CallbackHandler($formatter);
34
            }
35
        }
36
37 6
        foreach ($this->handlers as $key => $handler) {
38 3
            if (is_callable($handler)) {
39 3
                $this->handlers[$key] = new CallbackHandler($handler);
40
            }
41
        }
42
43
        return [
44 6
            new WhoopsProvider($this->handlers, $this->formatters)
45
        ];
46
    }
47
48
    /**
49
     * @return array
50
     */
51 1
    public function resolveBooboo() : array
52
    {
53
        return [
54 1
            new BoobooProvider($this->handlers, $this->formatters)
55
        ];
56
    }
57
58
    /**
59
     * @param  callable $callback
60
     * @return array
61
     */
62 1
    public function resolveCustom(callable $callback) : array
63
    {
64 1
        return $callback();
65
    }
66
67
    /**
68
     * @param mixed ...$handlers
69
     * @return $this
70
     */
71 3
    public function handlers(...$handlers)
72
    {
73 3
        $this->handlers = $handlers;
74
75 3
        return $this;
76
    }
77
78
    /**
79
     * @param mixed ...$formatters
80
     * @return $this
81
     */
82 3
    public function formatters(...$formatters)
83
    {
84 3
        $this->formatters = $formatters;
85
86 3
        return $this;
87
    }
88
}
89