Completed
Branch master (3adcdb)
by Raffael
08:09 queued 04:17
created

AbstractBootstrap::loadAppConfigs()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 20
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 8.8571
c 0
b 0
f 0
cc 5
eloc 11
nc 4
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * balloon
7
 *
8
 * @copyright   Copryright (c) 2012-2018 gyselroth GmbH (https://gyselroth.com)
9
 * @license     GPL-3.0 https://opensource.org/licenses/GPL-3.0
10
 */
11
12
namespace Balloon\Bootstrap;
13
14
use ErrorException;
15
use Psr\Log\LoggerInterface;
16
17
abstract class AbstractBootstrap
18
{
19
    /**
20
     * Logger.
21
     *
22
     * @var LoggerInterface
23
     */
24
    protected $logger;
25
26
    /**
27
     * Inject object.
28
     *
29
     * @param mixed $object
30
     *
31
     * @return AbstractBootstrap
32
     */
33
    public function inject($object): self
0 ignored issues
show
Unused Code introduced by
The parameter $object is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
    {
35
        return $this;
36
    }
37
38
    /**
39
     * Set error handler.
40
     *
41
     * @return AbstractBootstrap
42
     */
43
    protected function setErrorHandler(): self
44
    {
45
        set_error_handler(function ($severity, $message, $file, $line) {
46
            $log = $message.' in '.$file.':'.$line;
47
48
            switch ($severity) {
49
                case E_ERROR:
50
                case E_USER_ERROR:
51
                    $this->logger->error($log, [
52
                        'category' => get_class($this),
53
                    ]);
54
55
                break;
56
                case E_WARNING:
57
                case E_USER_WARNING:
58
                    $this->logger->warning($log, [
59
                        'category' => get_class($this),
60
                    ]);
61
62
                break;
63
                default:
64
                    $this->logger->debug($log, [
65
                        'category' => get_class($this),
66
                    ]);
67
68
                break;
69
            }
70
71
            throw new ErrorException($message, 0, $severity, $file, $line);
72
        });
73
74
        return $this;
75
    }
76
}
77