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.

Utility   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 49
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A normalize() 0 15 3
A commas() 0 3 1
A merge() 0 3 1
1
<?php
2
3
/**
4
 * Utility class.
5
 *
6
 * Provides methods for manipulating and extracting data from arrays.
7
 *
8
 * @license    http://opensource.org/licenses/MIT The MIT License (MIT)
9
 * @author     Omar El Gabry <[email protected]>
10
 */
11
class Utility{
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
12
13
    private function __construct(){}
14
15
    /**
16
     * Normalizes an array, and converts it to a standard format.
17
     *
18
     * @param  array $arr
19
     * @return array normalized array
20
     */
21
    public static function normalize($arr){
22
23
        $keys = array_keys($arr);
24
        $count = count($keys);
25
26
        $newArr = [];
27
        for ($i = 0; $i < $count; $i++) {
28
            if (is_int($keys[$i])) {
29
                $newArr[$arr[$keys[$i]]] = null;
30
            } else {
31
                $newArr[$keys[$i]] = $arr[$keys[$i]];
32
            }
33
        }
34
        return $newArr;
35
    }
36
37
    /**
38
     * returns a string by separating array elements with commas
39
     *
40
     * @param  array $arr
41
     * @return array
42
     */
43
    public static function commas($arr){
44
        return implode(",", (array)$arr);
45
    }
46
47
    /**
48
     * Merging two arrays
49
     *
50
     * @param  mixed   $arr1
51
     * @param  mixed   $arr2
52
     * @return array   The merged array
53
     *
54
     */
55
    public static function merge($arr1, $arr2){
56
        return array_merge((array)$arr1, (array)$arr2);
57
    }
58
59
 }
60