BoolReplacingStrategy::replace()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 9
c 0
b 0
f 0
ccs 5
cts 5
cp 1
rs 10
cc 3
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Xsolve\SalesforceClient\QueryBuilder\Visitor\Parameters;
4
5
class BoolReplacingStrategy implements ReplacingStrategyInterface
6
{
7 9
    public function isApplicable(Type $type): bool
8
    {
9 9
        return Type::BOOL() === $type;
10
    }
11
12 7
    public function replace($value): string
13
    {
14 7
        if (in_array($value, ['true', 'false'], true)) {
15 2
            return $value;
16
        }
17
18 5
        $boolValue = (bool) $value;
19
20 5
        return $boolValue ? 'true' : 'false';
21
    }
22
}
23