Passed
Push — master ( 613632...34a5a5 )
by Akpé Aurelle Emmanuel Moïse
01:34
created

namedArgsHelper::getReflection()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace EZAMA{
4
    class namedArgsHelper
5
    {
6
        protected static function merge(&$arr1, &$arr2)
7
        {
8
            foreach ($arr1 as $k=>$v) {
9
                if (array_key_exists($k, $arr2)) {
10
                    $arr1[$k]=&$arr2[$k];
11
                }
12
            }
13
        }
14
        
15
        protected static function format($OneDarray)
16
        {
17
            if (!\is_array($OneDarray)) {
18
                return '';
19
            }
20
            if (\count($OneDarray)>1) {
21
                $end=array_pop($OneDarray);
22
                return \join(',', $OneDarray)." and $end ";
23
            } else {
24
                return array_pop($OneDarray);
25
            }
26
        }
27
        
28
        protected static function throwError($error)
29
        {
30
            $error=(string)($error);
31
            if (\version_compare(\PHP_VERSION, '7.0.0') < 0) {
32
                \trigger_error($error, \E_USER_ERROR);
33
            } else {
34
                throw new \Error($error);
35
            }
36
        }
37
        
38
        protected static function is_valid_associative($array)
39
        {
40
            if (!\is_array($array)) {
41
                return \false;
42
            }
43
            foreach ($array as $k=>$v) {
44
                if (!\preg_match('#^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$#', (string)$k)) {
45
                    return \false;
46
                }
47
            }
48
            return \true;
49
        }
50
        
51
        protected static function getReflection(&$func)
52
        {
53
            if (!\is_string($func)) {
54
                throw new \BadFunctionCallException('Try to call undefined Function');
55
            }
56
            try {
57
                $func = new \reflectionFunction($func);
58
            } catch (\ReflectionException $e) {
59
                throw new \BadFunctionCallException('Try to call undefined Function');
60
            }
61
        }
62
    }
63
}
64