Cleaner.php ➔ get_length()   A
last analyzed

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
if (! function_exists('trim_doubled_space')) {
12
    function trim_doubled_space($value)
13
    {
14 1
        return preg_replace('/^\s+|\s+$/', '', $value);
15
    }
16
}
17
18
if (! function_exists('is_valid_type_for_length')) {
19
    function is_valid_type_for_length($value)
20
    {
21 5
        if (is_array($value) || is_string($value)) {
22 5
            return true;
23
        }
24
25
        return false;
26
    }
27
}
28
29
if (! function_exists('get_length')) {
30
    function get_length($value)
31
    {
32 5
        if (is_array($value)) {
33
            return count($value);
34
        }
35
36 5
        if (is_string($value)) {
37 5
            return strlen($value);
38
        }
39
40
        return 0;
41
    }
42
}