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 ( 9c92ff...7f0c85 )
by Vermeulen
02:33
created

Datas   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
D checkTypes() 0 34 10
1
<?php
2
3
namespace BFW\Helpers;
4
5
class Datas
6
{
7
    /**
8
     * Check types of variables
9
     * 
10
     * @param array $vars : Variables to check
11
     *  array(array('type' => 'monType', 'data' => 'mesData), array(...)...)
12
     * 
13
     * @return boolean
14
     */
15
    public static function checkTypes($vars)
16
    {
17
        if (!is_array($vars)) {
18
            return false;
19
        }
20
21
        foreach ($vars as $var) {
22
            if (!is_array($var)) {
23
                return false;
24
            }
25
26
            if (!(!empty($var['type']) && isset($var['data']))) {
27
                return false;
28
            }
29
30
            if (!is_string($var['type'])) {
31
                return false;
32
            }
33
34
            if ($var['type'] === 'int') {
35
                $var['type'] = 'integer';
36
            }
37
38
            if ($var['type'] === 'float') {
39
                $var['type'] = 'double';
40
            }
41
42
            if (gettype($var['data']) !== $var['type']) {
43
                return false;
44
            }
45
        }
46
47
        return true;
48
    }
49
}