Completed
Push — master ( 2454a8...540363 )
by Tom
15:51
created

StringTyped::parseBoolOption()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Util;
9
10
/**
11
 * StringTyped String formatter / parser
12
 *
13
 * @package N98\Util
14
 */
15
abstract class StringTyped
16
{
17
    /**
18
     * @param string $value
19
     * @return bool
20
     */
21
    public static function parseBoolOption($value)
22
    {
23
        return in_array(strtolower($value), array('y', 'yes', 1, 'true'));
24
    }
25
26
    /**
27
     * @param string $value
28
     * @return string
29
     */
30
    public static function formatActive($value)
31
    {
32
        if (in_array($value, array(1, 'true'))) {
33
            return 'active';
34
        }
35
36
        return 'inactive';
37
    }
38
}
39