ParentsStrategy::identifyParentsTypes()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
c 0
b 0
f 0
rs 9.4285
cc 3
eloc 8
nc 3
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: toor
5
 * Date: 18.03.18
6
 * Time: 23:02
7
 */
8
9
namespace Symfony\Component\Debug\Extension\Strategies;
10
11
12
use Exception;
13
14
/**
15
 * Class ParentsStrategy
16
 * @package Symfony\Component\Debug\Extension\Strategies
17
 */
18
class ParentsStrategy extends SimpleStrategy {
19
20
    /**
21
     * @param Exception $exception
22
     * @return array
23
     */
24
    protected function identifyParentsTypes(Exception $exception) {
25
26
        $parents = class_parents($exception);
27
28
        if (false === $parents) {
29
            return array();
30
        }
31
32
        $parents = array_keys($parents);
33
34
        if (null === $parents) {
35
            return array();
36
        }
37
38
        return array_reverse($parents);
39
    }
40
41
42
    /**
43
     * {@inheritdoc}
44
     */
45
    public function handle(Exception $exception) {
46
47
        $type = $this->identifyExceptionType($exception);
48
        $parents = $this->identifyParentsTypes($exception);
49
50
        foreach ($parents as $parent) {
51
52
            $isProcessed = $this->run($parent, $exception);
53
54
            if (true === $isProcessed) {
55
                break;
56
            }
57
        }
58
59
        return $this->run($type, $exception);
60
    }
61
}
62