DateTimeCreator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getNowDateTime() 0 10 2
1
<?php
2
3
namespace Smartbox\CoreBundle\Utils\Helper;
4
5
class DateTimeCreator
6
{
7
    /**
8
     * Using the same strategy as Monolog does for creating time stamps with micro seconds.
9
     *
10
     * microtime without \ is used as it we need to be able to ClockMock it.
11
     *
12
     * @return \DateTime
13
     */
14
    public static function getNowDateTime()
15
    {
16
        if (PHP_VERSION_ID < 70100) {
17
            $now = \DateTime::createFromFormat('U.u', \sprintf('%.6F', microtime(true)));
0 ignored issues
show
Comprehensibility Best Practice introduced by
The expression \DateTime::createFromFor...6F', microtime(true))); of type DateTime|false adds false to the return on line 22 which is incompatible with the return type documented by Smartbox\CoreBundle\Util...Creator::getNowDateTime of type DateTime. It seems like you forgot to handle an error condition.
Loading history...
18
        } else {
19
            $now = new \DateTime(null);
20
        }
21
22
        return $now;
23
    }
24
}
25