DispatchErrorEventThrowableHandler   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 5
c 1
b 0
f 0
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handleThrowable() 0 5 1
A __construct() 0 3 1
1
<?php
2
3
/**
4
 * This file is part of coisa/error-handler.
5
 *
6
 * (c) Felipe Sayão Lobato Abreu <[email protected]>
7
 *
8
 * This source file is subject to the license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
declare(strict_types=1);
13
14
namespace CoiSA\ErrorHandler\Handler;
15
16
use CoiSA\ErrorHandler\EventDispatcher\Event\ErrorEvent;
17
use Psr\EventDispatcher\EventDispatcherInterface;
18
19
/**
20
 * Class DispatchErrorEventThrowableHandler
21
 *
22
 * @package CoiSA\ErrorHandler\Handler
23
 */
24
final class DispatchErrorEventThrowableHandler implements ThrowableHandlerInterface
25
{
26
    /**
27
     * @var EventDispatcherInterface
28
     */
29
    private $eventDispatcher;
30
31
    /**
32
     * DispatchEventThrowableHandler constructor.
33
     *
34
     * @param EventDispatcherInterface $eventDispatcher
35
     */
36 34
    public function __construct(EventDispatcherInterface $eventDispatcher)
37
    {
38 34
        $this->eventDispatcher = $eventDispatcher;
39 34
    }
40
41
    /**
42
     * @param \Throwable $throwable
43
     */
44 1
    public function handleThrowable(\Throwable $throwable): void
45
    {
46 1
        $event = new ErrorEvent($throwable);
47
48 1
        $this->eventDispatcher->dispatch($event);
49 1
    }
50
}
51