$params]; } elseif (is_array($params)) { $first = reset($params); if (is_numeric($first) && is_int(key($params))) { $params['max'] = $first; } } return $params; } /** * @param int $max * @return bool */ protected function setMax($max): bool { if (! is_numeric($max) || intval($max) <= 0) { return false; } $this->max = $this->replace['max'] = intval($max); return true; } /** * @param int $max * @return static */ public function max($max) { $this->setMax($max); return $this; } public function check(&$value) { $number = $this->toNumber($value); if ($number === false) { return false; } return $number <= $this->max; } /** * Default message * @return string */ public function defaultMessage(): string { return _t('error', 'The [attribute] must be less than [max]'); } }