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::_applies()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 2
eloc 6
nc 2
nop 0
crap 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