BaseStrategy::registerHandler()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: toor
5
 * Date: 19.03.18
6
 * Time: 23:20
7
 */
8
9
namespace Symfony\Component\Debug\Extension\Strategies;
10
11
12
use Exception;
13
use Symfony\Component\Debug\Extension\Api\ErrorHandlerInterface;
14
15
/**
16
 * Class BaseStrategy
17
 * @package Symfony\Component\Debug\Extension\Strategies
18
 */
19
abstract class BaseStrategy {
20
21
    /**
22
     * @var ErrorHandlerInterface[] $handlers
23
     */
24
    protected $handlers = array();
25
26
27
    /**
28
     * @param ErrorHandlerInterface $errorHandler
29
     * @param string $type
30
     * @return int
31
     */
32
    public function registerHandler(ErrorHandlerInterface $errorHandler, $type = '') {
33
34
        if ('' === $type) {
35
            return array_push($this->handlers, $errorHandler);
36
        }
37
38
        $this->handlers[$type] = $errorHandler;
39
40
        return count($this->handlers);
41
    }
42
43
44
    /**
45
     * @param Exception $exception
46
     * @return bool Did you manage to process the error
47
     */
48
    abstract public function handle(Exception $exception);
49
}
50