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 ( c3085b...827fa4 )
by Vermeulen
02:56
created

Datas::checkType()   D

Complexity

Conditions 10
Paths 13

Size

Total Lines 34
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 34
rs 4.8196
cc 10
eloc 17
nc 13
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 (!(!empty($var['type']) && isset($var['data']))) {
30
                return false;
31
            }
32
33
            if (!is_string($var['type'])) {
34
                return false;
35
            }
36
37
            if ($var['type'] === 'int') {
38
                $var['type'] = 'integer';
39
            }
40
41
            if ($var['type'] === 'float') {
42
                $var['type'] = 'double';
43
            }
44
45
            if (gettype($var['data']) !== $var['type']) {
46
                return false;
47
            }
48
        }
49
50
        return true;
51
    }
52
53
    /**
54
     * Check if an email address is valid
55
     * 
56
     * @param string $mail The email address to check
57
     * 
58
     * @return boolean
59
     */
60
    public static function checkMail($mail)
61
    {
62
        return Secure::securise($mail, 'email');
0 ignored issues
show
Bug introduced by
The call to securise() misses a required argument $htmlentities.

This check looks for function calls that miss required arguments.

Loading history...
63
    }
64
}
65