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

LogExceptionHandler::handleException()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 2
dl 0
loc 9
ccs 0
cts 8
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
}