TDatetime   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 20
c 0
b 0
f 0
wmc 3
lcom 0
cbo 1
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isEscapeRequired() 0 4 1
A format() 0 9 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Puzzle\QueryBuilder\Types;
6
7
class TDatetime extends AbstractType
8
{
9
    const
10
        MYSQL_DATETIME_FORMAT = 'Y-m-d H:i:s';
11
12 21
    public function isEscapeRequired(): bool
13
    {
14 21
        return true;
15
    }
16
17 24
    public function format($value)
18
    {
19 24
        if($value instanceof \DateTime)
20
        {
21 7
            return $value->format(self::MYSQL_DATETIME_FORMAT);
22
        }
23
24 19
        return (string) $value;
25
    }
26
}
27