free()   A
last analyzed

Complexity

Conditions 6
Paths 6

Size

Total Lines 23
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 6.2163

Importance

Changes 0
Metric Value
cc 6
eloc 11
c 0
b 0
f 0
nc 6
nop 1
dl 0
loc 23
ccs 9
cts 11
cp 0.8182
crap 6.2163
rs 9.2222
1
<?php
2
3
4
/**
5
 * Random
6
 *
7
 * @param int $length
8
 *
9
 * @return int
10
 */
11
function msgRandom($length = 5): int
12
{
13 1
    $start = (int)str_pad(1, $length, '0', STR_PAD_RIGHT);
14 1
    $end = (int)str_pad(9, $length, '9', STR_PAD_RIGHT);
15
16 1
    return mt_rand($start, $end);
17
}
18
19
/**
20
 * parameterList
21
 *
22
 * @param \EasyIM\Kernel\Parameter ...$parameters
23
 *
24
 * @return \EasyIM\Kernel\ParameterList
25
 */
26
function parameterList(\EasyIM\Kernel\Parameter ...$parameters)
27
{
28 1
    return new EasyIM\Kernel\ParameterList(...$parameters);
29
}
30
31
/**
32
 *
33
 * @param mixed $value
34
 *
35
 * @return bool
36
 */
37
function free($value)
38
{
39 1
    if (is_null($value)) {
40 1
        return true;
41
    }
42
43 1
    if (is_string($value)) {
44 1
        return trim($value) === '';
45
    }
46
47 1
    if (is_numeric($value)) {
48
        return false;
49
    }
50
51 1
    if (is_bool($value)) {
52 1
        return true;
53
    }
54
55 1
    if ($value instanceof Countable) {
56
        return count($value) === 0;
57
    }
58
59 1
    return empty($value);
60
}
61