Datetime   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%
Metric Value
dl 0
loc 20
wmc 3
lcom 0
cbo 1
ccs 7
cts 7
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
namespace Muffin\Types;
4
5
class Datetime extends AbstractType
6
{
7
    const
8
        MYSQL_DATETIME_FORMAT = 'Y-m-d H:i:s';
9
10 21
    public function isEscapeRequired()
11
    {
12 21
        return true;
13
    }
14
15 24
    public function format($value)
16
    {
17 24
        if($value instanceof \DateTime)
18 24
        {
19 7
            return $value->format(self::MYSQL_DATETIME_FORMAT);
20
        }
21
22 19
        return (string) $value;
23
    }
24
}
25