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
Pull Request — master (#68)
by Vermeulen
02:15
created

Observer   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 91
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 2.44%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 91
rs 10
ccs 1
cts 41
cp 0.0244
wmc 11
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A update() 0 4 1
C updateWithAction() 0 70 10
1
<?php
2
/**
3
 * Classes en rapport avec les observers
4
 * @author Vermeulen Maxime <[email protected]>
5
 * @version 1.0
6
 */
7
8
namespace BFW;
9
10
use \Exception;
11
use \SplSubject;
12
13
/**
14
 * Classe Observer
15
 * @package bfw
16
 */
17
class Observer implements \SplObserver
18
{
19
    /**
20
     * Méthode par défaut appelé lorsque l'observer se déclanche
21
     * 
22
     * @param SplSubject $subject Le sujet déclanchant l'observer
23
     */
24
    public function update(SplSubject $subject)
25
    {
26
        
27 1
    }
28
    
29
    /**
30
     * Méthode appelé lorsque l'observer se déclanche via la classe Kernel
31
     * 
32
     * @param SplSubject $subject Le sujet déclanchant l'observer
33
     * @param string     $action  L'action à faire lors du déclanchement
34
     * 
35
     * @throws \Exception : Si le paramètre $subject n'est pas un objet ou n'est pas une instance de \BFW\Kernel
36
     */
37
    public function updateWithAction($subject, $action)
38
    {
39
        if(!is_object($subject))
40
        {
41
            throw new Exception('Le paramètre $subject doit être un objet.');
42
        }
43
        elseif(is_object($subject) && get_class($subject) != '\SplSubject')
44
        {
45
            throw new Exception('Le paramètre $subject doit être un objet de type \SplSubject.');
46
        }
47
        
48
        //Gestion de l'action.
49
        /*
50
         * $action : 
51
         *  Maclass::MaMethode()
52
         *  Maclass->MaMethode()
53
         *  MaFonction()
54
        */
55
        //Il faut gérer la porter des variables (classe/arguments)
56
        
57
        $class = null;
58
        $args = null;
0 ignored issues
show
Unused Code introduced by
$args is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
59
        
60
        $match = array();
61
        $regex = '([0-9a-zA-Z.,_-]+)';
62
        $regex2 = '([0-9a-zA-Z.,_-]*)';
63
        
64
        if(strpos($action, '::') !== false)
65
        {
66
            $preg_match = preg_match('^'.$regex.'::'.$regex.'\('.$regex2.'\);$', $action, $match);
67
            $class = $match[1];
68
            $args = $match[3];
69
        }
70
        elseif(strpos($action, '->') !== false)
71
        {
72
            $preg_match = preg_match('^'.$regex.'::'.$regex.'\('.$regex2.'\);$', $action, $match);
73
            $class = $match[1];
74
            $args = $match[3];
75
        }
76
        else
77
        {
78
            $preg_match = preg_match('^'.$regex.'\('.$regex2.'\);$', $action, $match);
79
            $args = $match[2]; 
80
        }
81
        
82
        if(!is_null($class))
83
        {
84
            $class = str_replace('$', '', $class);
85
            global ${$class};
86
        }
87
             
88
        if(!is_null($args))
89
        {
90
            $args = explode(',', $args);
91
            foreach($args as $arg)
92
            {
93
                $arg = str_replace('$', '', $arg);
94
                global ${$arg};
95
            }
96
        }
97
        
98
        try
99
        {
100
            eval($action);
101
        }
102
        catch(\Exception $e)
0 ignored issues
show
Unused Code introduced by
catch (\Exception $e) { ...cho $e->getMessage(); } does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
103
        {
104
            echo $e->getMessage();
105
        }
106
    }
107
}
108