DateTimeReplacingStrategy::replace()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 11
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10
cc 3
nc 4
nop 1
crap 3
1
<?php
2
3
namespace Xsolve\SalesforceClient\QueryBuilder\Visitor\Parameters;
4
5
class DateTimeReplacingStrategy implements ReplacingStrategyInterface
6
{
7 13
    public function isApplicable(Type $type): bool
8
    {
9 13
        return Type::DATETIME() === $type;
10
    }
11
12 4
    public function replace($value): string
13
    {
14 4
        if (is_int($value)) {
15 2
            $value = sprintf('@%d', $value);
16
        }
17
18 4
        if (!$value  instanceof \DateTimeInterface) {
19 3
            $value = new \DateTime($value);
20
        }
21
22 4
        return $value->format('c');
23
    }
24
}
25