Completed
Push — master ( e344b5...6c2145 )
by Nicolò
02:04
created

BooleanString   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 26
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A toBool() 0 4 1
1
<?php
2
3
namespace ValueObjects\Boolean;
4
5
use ValueObjects\Exception\InvalidNativeArgumentException;
6
use ValueObjects\StringLiteral\StringLiteral;
7
8
class BooleanString extends StringLiteral
9
{
10
    /**
11
     * Returns a BooleanString object
12
     *
13
     * @param string $value
14
     */
15 28
    public function __construct($value)
16
    {
17 28
        if (null === \filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE)) {
18 1
            throw new InvalidNativeArgumentException($value, array('string (boolean value)'));
19
        }
20
21 27
        $this->value = $value;
22 27
    }
23
24
    /**
25
     * Returns the bool value of the BooleanString
26
     *
27
     * @return bool
28
     */
29 18
    public function toBool()
30
    {
31 18
        return \filter_var($this->value, FILTER_VALIDATE_BOOLEAN);
32
    }
33
}
34