Completed
Push — master ( 7942ad...1c8947 )
by WEBEWEB
01:50
created

BooleanUtility::parseString()   B

Complexity

Conditions 9
Paths 9

Size

Total Lines 16
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 16
rs 7.756
cc 9
eloc 13
nc 9
nop 1
1
<?php
2
3
/**
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2017 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\Utility\Argument;
13
14
/**
15
 * Boolean utility
16
 *
17
 * @author webeweb <https://github.com/webeweb/>
18
 * @package WBW\Library\Core\Utility\Argument
19
 * @final
20
 */
21
final class BooleanUtility {
22
23
    /**
24
     * Parse a string.
25
     *
26
     * @param string $value The string value.
27
     * @return boolean Returns true in case of success, false otherwise.
28
     */
29
    public static function parseString($value) {
30
        if (null === $value) {
31
            return false;
32
        }
33
        switch (strtolower($value)) {
34
            case "1":
35
            case "o":
36
            case "ok":
37
            case "oui":
38
            case "true":
39
            case "y":
40
            case "yes":
41
                return true;
42
        }
43
        return false;
44
    }
45
46
}
47