BooleanType::convertToModlrValue()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
rs 9.2
cc 4
eloc 8
nc 4
nop 1
1
<?php
2
3
namespace As3\Modlr\DataTypes\Types;
4
5
/**
6
 * The boolean data type converter.
7
 *
8
 * @author Jacob Bare <[email protected]>
9
 */
10
class BooleanType implements TypeInterface
11
{
12
    /**
13
     * {@inheritDoc}
14
     */
15
    public function convertToModlrValue($value)
16
    {
17
        if (null === $value) {
18
            return $value;
19
        }
20
        if ('true' === strtolower($value)) {
21
            return true;
22
        }
23
        if ('false' === strtolower($value)) {
24
            return false;
25
        }
26
        return (Boolean) $value;
27
    }
28
}
29