Passed
Push — master ( 48754b...bf5028 )
by Radu
01:13
created

Dates::format()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
namespace WebServCo\Framework\Utils;
3
4
final class Dates
5
{
6
    public static function format($date, $format = 'Y-m-d')
7
    {
8
        $dateTime = \DateTime::createFromFormat($format, $date);
9
        if (false == $dateTime) {
10
            return false;
11
        }
12
        return $dateTime->format($format);
13
    }
14
15
    public static function isDate($date, $format = 'Y-m-d')
16
    {
17
        $formattedDate = self::format($date, $format);
18
        return $formattedDate == $date;
19
    }
20
}
21