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   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 13
c 4
b 0
f 0
lcom 0
cbo 1
dl 0
loc 64
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
C checkType() 0 35 11
A checkMail() 0 10 2
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