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

Dates   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 7
dl 0
loc 15
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isDate() 0 4 1
A format() 0 7 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