= (float)PHP_INT_MAX) { return null; } } $integer = (int)$number; return $integer < $minimum ? null : $integer; } /** * read(), with a caller-supplied answer for "this value is unreadable". * * For the many call sites whose domain has a sentinel already -- -1 for "no * coordinate", 0 for "not supplied" -- so an unreadable field and an absent * one land on the same value without each site repeating the null check. * * @param mixed $value * @param int $minimum Smallest value the field's documented domain allows. * @param int $whenUnreadable Returned when $value does not spell a whole * number at or above $minimum. */ public static function readOr($value, int $minimum, int $whenUnreadable): int { $read = self::read($value, $minimum); return $read === null ? $whenUnreadable : $read; } }