function dateIsValid() does not seem to conform to the naming convention (^(?:is|has|should|may|supports)).
This check examines a number of code elements and verifies that they conform
to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties,
methods, parameters, interfaces, classes, exceptions and special methods.
Loading history...
45
{
46
if ($date === null) {
47
return false;
48
}
49
$d = \DateTime::createFromFormat($format, $date);
50
51
return $d && $d->format($format) === $date;
52
}
53
54
/**
55
* Date to DateTime.
56
*
57
* @param mixed $date
58
*
59
* @return \DateTime
60
*/
61
public static function dateToDatetime($date): \DateTime
62
{
63
// DateTime
64
if ($date instanceof \DateTime) {
65
return $date;
66
}
67
// timestamp or AAAA-MM-DD
68
if (is_numeric($date)) {
69
return (new \DateTime())->setTimestamp($date);
70
}
71
// string (ie: '01/01/2019', 'today')
72
if (is_string($date)) {
73
return new \DateTime($date);
74
}
75
}
76
77
/**
78
* Format class name.
79
*
80
* @param \object $class
81
* @param array $options
82
*
83
* @return string
84
*/
85
public static function formatClassName($class, array $options = []): string
This check examines a number of code elements and verifies that they conform to the given naming conventions.
You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.