Completed
Push — master ( 44b4d6...c54f73 )
by WEBEWEB
06:15
created

BooleanHelper::parseString()   B

Complexity

Conditions 9
Paths 9

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 8.0555
c 0
b 0
f 0
cc 9
nc 9
nop 1
1
<?php
2
3
/**
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2018 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\Helper\Argument;
13
14
/**
15
 * Boolean helper.
16
 *
17
 * @author webeweb <https://github.com/webeweb/>
18
 * @package WBW\Library\Core\Helper\Argument
19
 */
20
class BooleanHelper {
21
22
    /**
23
     * Parse a string.
24
     *
25
     * @param string $value The string value.
26
     * @return boolean Returns true in case of success, false otherwise.
27
     */
28
    public static function parseString($value) {
29
        if (null === $value) {
30
            return false;
31
        }
32
        switch (strtolower($value)) {
33
            case "1":
34
            case "o":
35
            case "ok":
36
            case "oui":
37
            case "true":
38
            case "y":
39
            case "yes":
40
                return true;
41
        }
42
        return false;
43
    }
44
45
}
46