StringUtilities::booleanLiteral()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 2
nc 2
nop 1
crap 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