Boolean   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandleFrom() 0 4 1
A canHandleTo() 0 4 2
A convertTo() 0 4 1
A convertFrom() 0 4 2
1
<?php
2
3
namespace Benrowe\Laravel\Config\Modifiers;
4
5
/**
6
 * Boolean modifier for Config
7
 *
8
 * @package Benrowe\Laravel\Config\Modifiers
9
 */
10
class Boolean implements Modifier
11
{
12
    /**
13
     * Determine if this value is boolean
14
     *
15
     * @param  string $value
16
     * @return boolean
17
     */
18
    public function canHandleFrom($value)
19
    {
20
        return is_bool($value);
21
    }
22
23
    /**
24
     * Determine if we can convert this string into a boolean
25
     * @param  string $value
26
     * @return boolean
27
     */
28
    public function canHandleTo($value)
29
    {
30
        return $value === 'true' || $value === 'false';
31
    }
32
33
    /**
34
     * Convert the string into the boolean
35
     *
36
     * @param  string|array $value
37
     * @return boolean
38
     */
39
    public function convertTo($value)
40
    {
41
        return $value === 'true';
42
    }
43
44
    /**
45
     * Convert the complex object back to a string
46
     *
47
     * @param  bool $value
48
     * @return string
49
     */
50
    public function convertFrom($value)
51
    {
52
        return $value === true ? 'true' : 'false';
53
    }
54
}
55