Completed
Pull Request — master (#12)
by Tyler
03:55
created

Component   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 1
cbo 0
dl 0
loc 42
ccs 6
cts 9
cp 0.6667
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldHandle() 0 3 1
A shouldntHandle() 0 11 3
1
<?php
2
3
namespace Tylercd100\LERN\Components;
4
5
use Exception;
6
7
abstract class Component {
8
9
    /**
10
     * @var array
11
     */
12
    protected $dontHandle = [];
13
14
    /**
15
     * @var array
16
     */
17
    private $absolutelyDontHandle = [
18
        Tylercd100\LERN\Exceptions\LERNExceptionInterface::class,
19
    ];
20
21
    /**
22
     * Determine if the exception is in the "do not report" list.
23
     *
24
     * @param  \Exception  $e
25
     * @return bool
26
     */
27
    protected function shouldHandle(Exception $e){
28
        return !$this->shouldHandle($e);
29
    }
30
31
    /**
32
     * Determine if the exception is in the "do not report" list.
33
     *
34
     * @param  \Exception  $e
35
     * @return bool
36
     */
37 9
    protected function shouldntHandle(Exception $e){
38 9
        $dontHandle = array_merge($this->dontHandle,$this->absolutelyDontHandle);
39
40 9
        foreach ($dontHandle as $type) {
41 9
            if ($e instanceof $type) {
42
                return true;
43
            }
44 9
        }
45
46 9
        return false;
47
    }
48
}