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 — 3.0 ( d405c3...1625ef )
by Vermeulen
02:14
created

Datas::checkType()   C

Complexity

Conditions 11
Paths 12

Size

Total Lines 35
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 35
rs 5.2653
cc 11
eloc 18
nc 12
nop 1

How to fix   Complexity   

Long Method

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:

1
<?php
2
3
namespace BFW\Helpers;
4
5
/**
6
 * Helpers to manage datas
7
 */
8
class Datas
9
{
10
    /**
11
     * Check types of variables
12
     * 
13
     * @param array $vars : Variables to check
14
     *  array(array('type' => 'monType', 'data' => 'mesData), array(...)...)
15
     * 
16
     * @return boolean
17
     */
18
    public static function checkType($vars)
19
    {
20
        if (!is_array($vars)) {
21
            return false;
22
        }
23
24
        foreach ($vars as $var) {
25
            if (!is_array($var)) {
26
                return false;
27
            }
28
29
            if (
30
                !isset($var['data'])
31
                || empty($var['type'])
32
                || (isset($var['type']) && !is_string($var['type']))
33
            ) {
34
                return false;
35
            }
36
37
            //str_replace('int', 'integer'...) : integer => integereger
1 ignored issue
show
Unused Code Comprehensibility introduced by
50% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
            if ($var['type'] === 'int') {
39
                $var['type'] = 'integer';
40
            }
41
42
            if ($var['type'] === 'float') {
43
                $var['type'] = 'double';
44
            }
45
46
            if (gettype($var['data']) !== $var['type']) {
47
                return false;
48
            }
49
        }
50
51
        return true;
52
    }
53
54
    /**
55
     * Check if an email address is valid
56
     * 
57
     * @param string $mail The email address to check
58
     * 
59
     * @return boolean
60
     */
61
    public static function checkMail($mail)
62
    {
63
        $securisedMail = Secure::securise($mail, 'email', false);
64
        
65
        if ($securisedMail === false) {
66
            return false;
67
        }
68
        
69
        return true;
70
    }
71
}
72