Completed
Pull Request — master (#17)
by
unknown
20:59
created

DateTimeCreator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 18
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
6
class DateTimeCreator
7
{
8
    /**
9
     * Using the same strategy as Monolog does for creating time stamps with micro seconds
10
     *
11
     * @return \DateTime
12
     */
13
    public static function getNowDateTime()
14
    {
15
        if (PHP_VERSION_ID < 70100) {
16
            $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 21 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...
17
        } else {
18
            $now = new \DateTime(null);
19
        }
20
21
        return $now;
22
    }
23
}