Completed
Pull Request — development (#673)
by Nick
12:54 queued 04:44
created

DateUtil::dateTimeFromMySqlFormat()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Oc\Util;
4
5
use DateTime;
6
7
class DateUtil
8
{
9
    const DATE_FORMAT_MYSQL = 'Y-m-d H:i:s';
10
11
    /**
12
     * @param string $date
13
     *
14
     * @return \DateTime
15
     */
16
    public static function dateTimeFromMySqlFormat($date)
17
    {
18
        return DateTime::createFromFormat(self::DATE_FORMAT_MYSQL, $date);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The expression \DateTime::createFromFor...E_FORMAT_MYSQL, $date); of type DateTime|false adds false to the return on line 18 which is incompatible with the return type documented by Oc\Util\DateUtil::dateTimeFromMySqlFormat of type DateTime. It seems like you forgot to handle an error condition.
Loading history...
19
    }
20
}
21