Passed
Push — master ( eae2ea...251e76 )
by
unknown
01:43
created

Cleaner.php ➔ get_length()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.576

Importance

Changes 0
Metric Value
cc 3
eloc 6
nc 3
nop 1
dl 0
loc 12
ccs 3
cts 5
cp 0.6
crap 3.576
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: harry
5
 * Date: 2/15/18
6
 * Time: 4:18 PM
7
 */
8
9
namespace PluginSimpleValidate\helper\Cleaner;
10
11
use PluginSimpleValidate\Exception\InvalidTypeParameter;
12
13
if (! function_exists('trim_doubled_space')) {
14
    function trim_doubled_space($value)
15
    {
16 4
        return preg_replace('/^\s+|\s+$/', '', $value);
17
    }
18
}
19
20
if (! function_exists('is_valid_type_for_length')) {
21
    function is_valid_type_for_length($value)
22
    {
23 1
        if (is_array($value) || is_string($value)) {
24 1
            return true;
25
        }
26
27
        return false;
28
    }
29
}
30
31
if (! function_exists('get_length')) {
32
    function get_length($value)
33
    {
34 1
        if (is_array($value)) {
35
            return count($value);
36
        }
37
38 1
        if (is_string($value)) {
39 1
            return strlen($value);
40
        }
41
42
        return 0;
43
    }
44
}