protected function isParsableImpl(&$value) {
        if (!parent::isParsableImpl($value)) {
            return FALSE;
        }

        $adjustedValue = strtoupper($value);
        $adjustedValueLength = strlen($adjustedValue);

        $isNumber = ($this->parse($adjustedValue) !== FALSE);

        // GOVDB-284. It is correct number. Adding check to prevent possible rounding or converting to scientific format by PHP
        if ($isNumber && ($adjustedValueLength > self::$MAX_DIGIT_NUMBER)) {
            $count = 0;
            for ($i = 0; $i < $adjustedValueLength; $i++) {
                $char = $adjustedValue[$i];
                if (($char >= '0') && ($char <= '9')) {
                    $count++;
                }
            }
            if ($count > self::$MAX_DIGIT_NUMBER) {
                $isNumber = FALSE;
            }
        }

        return $isNumber;
    }
 protected function isParsableImpl(&$value)
 {
     if (!parent::isParsableImpl($value)) {
         return FALSE;
     }
     $result = $this->testValue($value);
     return isset($result);
 }
    protected function isParsableImpl(&$value) {
        if (!parent::isParsableImpl($value)) {
            return FALSE;
        }

        // We need at least two '/', '-', '.' or ' ' to proceed
        $characterUsage = count_chars($value, 1);
        if (!$this->checkCharacterUsage($characterUsage)) {
            return FALSE;
        }

        return TRUE;
    }
Esempio n. 4
0
 protected function isParsableImpl(&$value)
 {
     if (!parent::isParsableImpl($value)) {
         return FALSE;
     }
     // Supported formats: m/d/y, d m y, d-m-y and d.m.y [plus optional time]
     $MIN_LENGTH_DATE = 6;
     // at least: day + separator + month + separator + year[2]
     if (strlen($value) < $MIN_LENGTH_DATE) {
         return FALSE;
     }
     // We need at least two '/', '-', '.' or ' ' to proceed
     $characterUsage = count_chars($value, 1);
     if (!$this->isDateSeparatorPresent($characterUsage, ' ') && !$this->isDateSeparatorPresent($characterUsage, '/') && !$this->isDateSeparatorPresent($characterUsage, '-') && !$this->isDateSeparatorPresent($characterUsage, '.')) {
         return FALSE;
     }
     return date_create($value) !== FALSE;
 }