Passed
Push — master ( 87b24e...d7d567 )
by Mike
07:22
created

LogExceptionHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 18
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A handleException() 0 9 1
1
<?php
2
3
4
namespace App\Application\Business\ExceptionHandler;
5
6
7
use DataProvider\LogMessageDataProvider;
8
use Xervice\Core\Factory\FactoryInterface;
9
use Xervice\Core\Locator\AbstractWithLocator;
10
use Xervice\ExceptionHandler\Business\Handler\ExceptionHandlerInterface;
11
12
/**
13
 * @method \App\Application\ApplicationFactory getFactory()
14
 */
15
class LogExceptionHandler extends AbstractWithLocator implements ExceptionHandlerInterface
16
{
17
18
    /**
19
     * @param \Exception $exception
20
     * @param bool $isDebug
21
     *
22
     * @throws \Core\Locator\Dynamic\ServiceNotParseable
23
     */
24
    public function handleException(\Exception $exception, bool $isDebug): void
25
    {
26
        $logMessage = new LogMessageDataProvider();
27
        $logMessage
28
            ->setTitle(get_class($exception))
29
            ->setMessage($exception->getMessage())
30
            ->setContext($exception->getTraceAsString());
31
32
        $this->getFactory()->getLoggerFacade()->log($logMessage);
33
    }
34
35
}