Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 8b84f12

Browse files
committed
chore: refactor comparable trait
1 parent 751a467 commit 8b84f12

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

src/Rule/Util/ComparableTrait.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@ private function isComparable(mixed $value1, mixed $value2): bool
2323

2424
private function convertToComparable(mixed $value): mixed
2525
{
26-
if (\is_string($value)) {
27-
// If is string and has only one char or is empty,
28-
// return value to avoid conflicting with DateTime formats
29-
if (\mb_strlen($value) <= 1) {
30-
return $value;
31-
}
32-
33-
// Guess if is a DateTime string and convert
34-
// (like "yesterday" or "1985-07-19")
26+
// Try to guess if it is a valid datetime format,
27+
// like "yesterday" or "1985-07-19"
28+
// https://www.php.net/manual/en/datetime.formats.php
29+
if (\is_string($value) && \mb_strlen($value) > 1) {
3530
try {
3631
return new \DateTimeImmutable($value);
3732
}

0 commit comments

Comments
 (0)