| Conditions | 16 |
| Paths | 42 |
| Total Lines | 89 |
| Code Lines | 58 |
| Lines | 9 |
| Ratio | 10.11 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 177 | else { |
||
| 178 | $mdpok = Encrypt::setEncryptMdp($new_mdp, $this->id_identite); |
||
| 179 | //le nouveau mdp est bon on update |
||
| 180 | $dbc->query("UPDATE identite SET mdp='$mdpok' WHERE ID_identite=".$this->id_identite); |
||
| 181 | |||
| 182 | $this->mdp = $mdpok; |
||
| 183 | } |
||
| 184 | } |
||
| 185 | } |
||
| 186 | } |
||
| 187 | //------------------------------ fin setter ----------------------------------- |
||
| 188 | |||
| 189 | |||
| 190 | //-------------------------- FONCTIONS SPECIFIQUES ----------------------------------------------------------------------------// |
||
| 191 | //-------------------------- FONCTIONS POUR TESTER SECURITE D'UN MDP ----------------------------------------------------------------------------// |
||
| 192 | /** |
||
| 193 | * Fonction qui permet de verifier la securite d'un mdp |
||
| 194 | * @param string $mdp |
||
| 195 | * @return integer |
||
| 196 | */ |
||
| 197 | function testpassword($mdp) { |
||
| 198 | $longueur = strlen($mdp); |
||
| 199 | $point = 0; |
||
| 200 | |||
| 201 | for ($i=0 ; $i<$longueur ; $i++) { |
||
| 202 | $lettre = $mdp[$i]; |
||
| 203 | |||
| 204 | if ($lettre >= 'a' && $lettre <= 'z') { |
||
| 205 | $point = $point + 1; |
||
| 206 | $point_min = 1; |
||
| 207 | } |
||
| 208 | else if ($lettre >= 'A' && $lettre <= 'Z'){ |
||
| 209 | $point = $point + 2; |
||
| 210 | $point_maj = 2; |
||
| 211 | } |
||
| 212 | else if ($lettre >= '0' && $lettre <= '9'){ |
||
| 213 | $point = $point + 3; |
||
| 214 | $point_chiffre = 3; |
||
| 215 | } |
||
| 216 | else { |
||
| 217 | $point = $point + 5; |
||
| 218 | $point_caracteres = 5; |
||
| 219 | } |
||
| 220 | } |
||
| 221 | |||
| 222 | // Calcul du coefficient points/longueur |
||
| 223 | $etape1 = $point / $longueur; |
||
| 224 | |||
| 225 | // Calcul du coefficient de la diversite des types de caracteres... |
||
| 226 | $etape2 = $point_min + $point_maj + $point_chiffre + $point_caracteres; |
||
| 227 | |||
| 228 | // Multiplication du coefficient de diversite avec celui de la longueur |
||
| 229 | $resultat = $etape1 * $etape2; |
||
| 230 | |||
| 231 | // Multiplication du resultat par la longueur de la chaene |
||
| 232 | $final = $resultat * $longueur; |
||
| 233 | |||
| 234 | return $final; |
||
| 235 | } |
||
| 236 | //-------------------------- FIN FONCTIONS POUR TESTER SECURITE D'UN MDP ----------------------------------------------------------------------------// |
||
| 237 | } |
There are different options of fixing this problem.
If you want to be on the safe side, you can add an additional type-check:
If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:
Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.