/** * Validates the parameters value and returns the result. * @see ParamDefinition::validateValue * * @since 0.5 * * @param $value mixed * @param $param IParam * @param $definitions array of IParamDefinition * @param $params array of IParam * @param ValidatorOptions $options * * @return boolean */ protected function validateValue($value, IParam $param, array $definitions, array $params, ValidatorOptions $options) { if ($options->isStringlyTyped()) { if (preg_match('/^(-)?\\d+((\\.|,)\\d+)?$/', $value)) { $value = (double) $value; } else { return false; } } elseif (!is_float($value) && !is_int($value)) { return false; } return parent::validateValue($value, $param, $definitions, $params, $options); }
/** * Sets the parameter definition values contained in the provided array. * @see ParamDefinition::setArrayValues * * @since 0.5 * * @param array $param */ public function setArrayValues(array $param) { parent::setArrayValues($param); if (array_key_exists('negatives', $param)) { $this->setAllowNegatives($param['negatives']); } }
/** * Sets the parameter definition values contained in the provided array. * @see ParamDefinition::setArrayValues * * @since 0.5 * * @param array $param */ public function setArrayValues(array $param) { parent::setArrayValues($param); if (array_key_exists('allowauto', $param)) { $this->setAllowAuto($param['allowauto']); } if (array_key_exists('maxpercentage', $param)) { $this->setMaxPercentage($param['maxpercentage']); } if (array_key_exists('minpercentage', $param)) { $this->setMinPercentage($param['minpercentage']); } if (array_key_exists('units', $param)) { $this->setAllowedUnits($param['units']); } if (array_key_exists('defaultunit', $param)) { $this->setDefaultUnit($param['defaultunit']); } }