Passed
Push — develop_3.0 ( 139f7f...a665b9 )
by Adrien
02:36
created

CellTypeHelper   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 0
dl 0
loc 46
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A isEmpty() 0 4 2
A isNonEmptyString() 0 4 2
A isNumeric() 0 6 2
A isBoolean() 0 4 1
1
<?php
2
3
namespace Box\Spout\Common\Helper;
4
5
/**
6
 * Class CellTypeHelper
7
 * This class provides helper functions to determine the type of the cell value
8
 */
9
class CellTypeHelper
10
{
11
    /**
12
     * @param $value
13
     * @return bool Whether the given value is considered "empty"
14
     */
15 119
    public static function isEmpty($value)
16
    {
17 119
        return ($value === null || $value === '');
18
    }
19
20
    /**
21
     * @param $value
22
     * @return bool Whether the given value is a non empty string
23
     */
24 111
    public static function isNonEmptyString($value)
25
    {
26 111
        return (gettype($value) === 'string' && $value !== '');
27
    }
28
29
    /**
30
     * Returns whether the given value is numeric.
31
     * A numeric value is from type "integer" or "double" ("float" is not returned by gettype).
32
     *
33
     * @param $value
34
     * @return bool Whether the given value is numeric
35
     */
36 114
    public static function isNumeric($value)
37
    {
38 114
        $valueType = gettype($value);
39
40 114
        return ($valueType === 'integer' || $valueType === 'double');
41
    }
42
43
    /**
44
     * Returns whether the given value is boolean.
45
     * "true"/"false" and 0/1 are not booleans.
46
     *
47
     * @param $value
48
     * @return bool Whether the given value is boolean
49
     */
50 122
    public static function isBoolean($value)
51
    {
52 122
        return gettype($value) === 'boolean';
53
    }
54
}
55