Completed
Push — master ( 30f3e2...473611 )
by Patrick
03:23
created

ExceptionHandlerProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Mosaic\Exceptions\Providers;
4
5
use Interop\Container\Definition\DefinitionProviderInterface;
6
use Mosaic\Exceptions\Runner;
7
8
abstract class ExceptionHandlerProvider implements DefinitionProviderInterface
9
{
10
    /**
11
     * @var array
12
     */
13
    protected $formatters;
14
15
    /**
16
     * @var array
17
     */
18
    protected $handlers;
19
20
    /**
21
     * @param array $handlers
22
     * @param array $formatters
23
     */
24 8
    public function __construct(array $handlers = [], array $formatters = [])
25
    {
26 8
        $this->formatters = $formatters;
27 8
        $this->handlers   = $handlers;
28 8
    }
29
30
    /**
31
     * Returns the definition to register in the container.
32
     *
33
     * Definitions must be indexed by their entry ID. For example:
34
     *
35
     *     return [
36
     *         'logger' => ...
37
     *         'mailer' => ...
38
     *     ];
39
     *
40
     * @return array
41
     */
42 2
    public function getDefinitions()
43
    {
44 2
        $runner = $this->getRunner();
45
46 2
        $runner->register();
47
48
        return [
49 2
            Runner::class => $runner
50
        ];
51
    }
52
53
    /**
54
     * @return Runner
55
     */
56
    abstract public function getRunner() : Runner;
57
}
58