Passed
Push — master ( d4d417...37f3ab )
by Mike
03:14
created

ExceptionHandlerFactory::createExceptionPrinter()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
5
namespace Xervice\ExceptionHandler;
6
7
8
use Xervice\ExceptionHandler\Business\Handler\DefaultExceptionHandler;
9
use Xervice\ExceptionHandler\Business\Handler\ExceptionHandlerInterface;
10
use Xervice\ExceptionHandler\Business\Printer\DebugPrinter;
11
use Xervice\ExceptionHandler\Business\Printer\ExceptionPrinterInterface;
12
use Xervice\Core\Factory\AbstractFactory;
13
14
/**
15
 * @method \Xervice\ExceptionHandler\ExceptionHandlerConfig getConfig()
16
 */
17
class ExceptionHandlerFactory extends AbstractFactory
18
{
19
    /**
20
     * @return \Xervice\ExceptionHandler\Business\Handler\DefaultExceptionHandler
21
     */
22 1
    public function createExceptionHandler(): ExceptionHandlerInterface
23
    {
24 1
        return new DefaultExceptionHandler(
25 1
            $this->createExceptionPrinter(),
26 1
            $this->getConfig()->shutdownIfError()
27
        );
28
    }
29
30
    /**
31
     * @return \Xervice\ExceptionHandler\Business\Printer\DebugPrinter
32
     */
33 1
    public function createExceptionPrinter(): ExceptionPrinterInterface
34
    {
35 1
        return new DebugPrinter(
36 1
            $this->getConfig()->isDebug()
37
        );
38
    }
39
}