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

Dates::isDate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
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