Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * 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);
     }
 }
Exemplo n.º 3
0
 /**
  * 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;
 }
Exemplo n.º 4
0
 /**
  * Is a control's value float number?
  * @return bool
  * @internal
  */
 public static function validateFloat(TextBase $control)
 {
     return Validators::isNumeric(static::filterFloat($control->getValue()));
 }
Exemplo n.º 5
0
 /**
  * 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;
 }