本文整理汇总了PHP中Nette\Utils\Validators::isNumeric方法的典型用法代码示例。如果您正苦于以下问题:PHP Validators::isNumeric方法的具体用法?PHP Validators::isNumeric怎么用?PHP Validators::isNumeric使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Utils\Validators
的用法示例。
在下文中一共展示了Validators::isNumeric方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateFloat
/**
* Is a control's value float number?
* @return bool
*/
public static function validateFloat(IControl $control)
{
$value = str_replace(array(' ', ','), array('', '.'), $control->getValue());
if (Validators::isNumeric($value)) {
$control->setValue((double) $value);
return TRUE;
}
return FALSE;
}
示例2: checkQuality
/**
* Check value of quality
*
* @param int|string $quality
* @param string $type
*/
private function checkQuality($quality)
{
// quality must be number or percent
if (Validators::is($quality, 'string') && !Validators::isNumeric($quality)) {
$msg = sprintf('Quality has unexpected format, "%s" given.', $quality);
throw new InvalidArgumentException($msg);
}
// quality cannot be negative number
if ((int) $quality < 0) {
$msg = sprintf('Quality must be greater than 0, "%s" given.', $quality);
throw new InvalidArgumentException($msg);
}
}
示例3: validateFloat
/**
* Is a control's value float number?
* @return bool
* @internal
*/
public static function validateFloat(TextBase $control)
{
$value = self::filterFloat($control->getValue());
if (Validators::isNumeric($value)) {
$control->setValue((double) $value);
return TRUE;
}
return FALSE;
}
示例4: validateFloat
/**
* Is a control's value float number?
* @return bool
* @internal
*/
public static function validateFloat(TextBase $control)
{
return Validators::isNumeric(static::filterFloat($control->getValue()));
}
示例5: parseNumericValue
/**
* Convert string -> int, string -> float because of textual x-www-form-data
* @param mixed $value
* @return mixed
*/
protected function parseNumericValue($value)
{
if (Validators::isNumericInt($value)) {
return (int) $value;
}
if (Validators::isNumeric($value)) {
return (double) $value;
}
return $value;
}