public function selectCompatible($datatype) {
        if ($datatype === NumberDataTypeHandler::DATA_TYPE) {
            return $datatype;
        }

        return parent::selectCompatible($datatype);
    }
Ejemplo n.º 2
0
 public function castValue($value)
 {
     $adjustedValue = parent::castValue($value);
     if (!isset($adjustedValue)) {
         return NULL;
     }
     // at first we try to cast to number. If that does not work we try to cast to percent
     $nf = new NumberFormatter(Environment::getInstance()->getLocale(), NumberFormatter::DECIMAL);
     $offset = 0;
     // we need to use $offset because in case of error parse() returns 0 instead of FALSE
     $n = $nf->parse($adjustedValue, NumberFormatter::TYPE_DOUBLE, $offset);
     if ($n === FALSE || $offset != strlen($adjustedValue)) {
         $n = $this->parse($adjustedValue);
     }
     if ($n === FALSE) {
         $this->errorCastValue($adjustedValue);
     }
     return $n;
 }