GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( 50cef7...02ca20 )
by Rolf
01:54
created

ExceptionSupressor   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 3
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 37
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A _applies() 0 9 2
1
<?php
2
namespace izzum\rules;
3
4
/**
5
 * Supresses an exception and returns either true or false in case a concrete
6
 * rule
7
 * throws an exception.
8
 * In case the original rule applies succesfully (a true or
9
 * false result) the result is passed back to the client.
10
 *
11
 * This rule is an implementation of the Decorator pattern and allows a client
12
 * to use rules with a consistent behaviour for exceptions.
13
 * 
14
 * @author Rolf Vreijdenberger
15
 * @link https://en.wikipedia.org/wiki/Decorator_pattern
16
 *      
17
 */
18
class ExceptionSupressor extends Rule {
19
    
20
    /**
21
     *
22
     * @var Rule
23
     */
24
    private $decoree;
25
    
26
    /**
27
     *
28
     * @var boolean
29
     */
30
    private $supressed_result;
31
32
    /**
33
     *
34
     * @param Rule $decoree            
35
     * @param boolean $supressed_result
36
     *            what to return in case the decorated rule
37
     *            throws an error
38
     */
39 2
    public function __construct(Rule $decoree, $supressed_result = false)
40
    {
41 2
        $this->decoree = $decoree;
42 2
        $this->supressed_result = $supressed_result;
43 2
    }
44
45 2
    public function _applies()
46
    {
47
        try {
48 2
            $output = (boolean) $this->decoree->applies();
49 2
        } catch(Exception $e) {
50 2
            $output = $this->supressed_result;
51
        }
52 2
        return $output;
53
    }
54
}
55