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

StringTyped   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 24
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A parseBoolOption() 0 4 1
A formatActive() 0 8 2
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