DateTimeType   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 20
ccs 8
cts 8
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getData() 0 8 2
A getValue() 0 8 2
1
<?php
2
3
namespace iMega\Formatter;
4
5
class DateTimeType extends GenericType
6
{
7 6
    public static function getData($value)
8
    {
9 6
        if (!$value instanceof \DateTime) {
10 4
            throw new FormatterException('It not DateTime');
11
        }
12
13 4
        return $value->format('Y-m-d H:i:s');
14
    }
15
16 6
    public static function getValue($value)
17
    {
18 6
        if (false === $dateTime = date_create_from_format('Y-m-d H:i:s', $value)) {
19 4
            throw new FormatterException('String not convert');
20
        }
21
22 2
        return $dateTime;
23
    }
24
}
25