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

DateTimeCreator::getNowDateTime()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
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
}