Passed
Pull Request — master (#683)
by Jonathan
02:21
created

BooleanStringFormatter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 19
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
B toBoolean() 0 17 5
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Tools;
6
7
use function strtolower;
8
9
class BooleanStringFormatter
10
{
11 12
    public static function toBoolean(string $value, bool $default) : bool
12
    {
13 12
        switch (strtolower($value)) {
14 12
            case 'true':
15 12
                return true;
16
17 1
            case '1':
18 1
                return true;
19
20 1
            case 'false':
21 1
                return false;
22
23 1
            case '0':
24 1
                return false;
25
26
            default:
27 1
                return $default;
28
        }
29
    }
30
}
31