StringUtilities   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 50%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 0
cbo 0
dl 0
loc 26
ccs 2
cts 4
cp 0.5
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isNullOrEmpty() 0 4 3
A booleanLiteral() 0 4 2
1
<?php
2
3
/**
4
 * @copyright 2017 Vladimir Jimenez
5
 * @license   https://github.com/allejo/PhpPulse/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\DaPulse\Utilities;
9
10
/**
11
 * This class contains static utilities used for validating strings
12
 *
13
 * @package allejo\DaPulse\Utilities
14
 * @since   0.1.0
15
 */
16
class StringUtilities
17
{
18
    /**
19
     * Determine whether a string is null or empty
20
     *
21
     * @param  string $string The string to test
22
     *
23
     * @return bool True if string is null or empty
24
     */
25
    public static function isNullOrEmpty ($string)
26
    {
27
        return (!isset($string) || empty($string) || ctype_space($string));
28
    }
29
30
    /**
31
     * Get the literal representation of a boolean value
32
     *
33
     * @param  bool $value A boolean value
34
     *
35
     * @return string True if a boolean is true
36
     */
37 5
    public static function booleanLiteral ($value)
38
    {
39 5
        return ($value) ? "true" : "false";
40
    }
41
}
42