Converter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getDateTime() 0 12 4
1
<?php
2
/**
3
 * GpsLab component.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2016, Peter Gribanov
7
 * @license   http://opensource.org/licenses/MIT
8
 */
9
10
namespace GpsLab\Bundle\DateBundle;
11
12
class Converter
13
{
14
    /**
15
     * @param mixed $date
16
     *
17
     * @return \DateTime
18
     */
19 8
    public function getDateTime($date)
20
    {
21 8
        if ($date instanceof \DateTimeInterface) {
22 4
            $date = new \DateTime($date->format(\DateTime::ISO8601));
23 8
        } elseif (is_numeric($date)) { // is UTS
24 2
            $date = (new \DateTime())->setTimestamp($date);
25 4
        } elseif (!($date instanceof \DateTime)) {
26 2
            $date = new \DateTime($date);
27 2
        }
28
29 8
        return $date;
30
    }
31
}
32