DateTimeReplacingStrategy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
eloc 7
dl 0
loc 18
c 0
b 0
f 0
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isApplicable() 0 3 1
A replace() 0 11 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