src/NumberValidator.php
protected function validateNumber($value)
    {
        $return = new ValidateResult($value, false);

        if (is_string($value)) {
            //Replace comma with dot
            $value = str_replace(',', '.', $value);
        }

        //Apply all rules
        if (!is_numeric($value) || filter_var($value, FILTER_VALIDATE_FLOAT) === false) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'type'
                ]
            ]);
        } elseif ($this->maximum !== null
            && ($value > $this->maximum
                || ($this->exclusiveMaximum === true && $value >= $this->maximum)
            )
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'maximum'
                ]
            ]);
        } elseif ($this->minimum !== null
            && ($value < $this->minimum
                || ($this->exclusiveMinimum === true && $value <= $this->minimum)
            )
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'minimum'
                ]
            ]);
        } elseif ($this->multipleOf !== null
            && fmod((float)$value, (float)$this->multipleOf) != 0
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'multipleOf'
                ]
            ]);
        } else {
            $return->errorObject = null;
            //Set status to success
            $return->status = true;
            //Type cast
            $return->value  = $this->cast($value);
        }

        return $return;
    }
protected function validateNumber($value)
    {
        $return = new ValidateResult($value, false);

        if (is_string($value)) {
            //Replace comma with dot
            $value = str_replace(',', '.', $value);
        }

        //Apply all rules
        if (!is_numeric($value) || filter_var($value, FILTER_VALIDATE_FLOAT) === false) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'type'
                ]
            ]);
        } elseif ($this->maximum !== null
            && ($value > $this->maximum
                || ($this->exclusiveMaximum === true && $value >= $this->maximum)
            )
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'maximum'
                ]
            ]);
        } elseif ($this->minimum !== null
            && ($value < $this->minimum
                || ($this->exclusiveMinimum === true && $value <= $this->minimum)
            )
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'minimum'
                ]
            ]);
        } elseif ($this->multipleOf !== null
            && fmod((float)$value, (float)$this->multipleOf) != 0
        ) {
            //error
            $return->errorObject = new IncorrectParametersException([
                [
                    'type' => static::getType(),
                    'failure' => 'multipleOf'
                ]
            ]);
        } else {
            $return->errorObject = null;
            //Set status to success
            $return->status = true;
            //Type cast
            $return->value  = $this->cast($value);
        }

        return $return;
    }
protected function validateNumber ( $ value ) { $ return = new ValidateResult ( $ value , false ) ; if ( is_string ( $ value ) ) { //Replace comma with dot $ value = str_replace ( ',' , '.' , $ value ) ; } //Apply all rules if ( ! is_numeric ( $ value ) || filter_var ( $ value , FILTER_VALIDATE_FLOAT ) === false ) { //error $ return -> errorObject = new IncorrectParametersException ( [ [ 'type' => static :: getType ( ) , 'failure' => 'type' ] ] ) ; } elseif ( $ this -> maximum !== null && ( $ value > $ this -> maximum || ( $ this -> exclusiveMaximum === true && $ value >= $ this -> maximum ) ) ) { //error $ return -> errorObject = new IncorrectParametersException ( [ [ 'type' => static :: getType ( ) , 'failure' => 'maximum' ] ] ) ; } elseif ( $ this -> minimum !== null && ( $ value < $ this -> minimum || ( $ this -> exclusiveMinimum === true && $ value <= $ this -> minimum ) ) ) { //error $ return -> errorObject = new IncorrectParametersException ( [ [ 'type' => static :: getType ( ) , 'failure' => 'minimum' ] ] ) ; } elseif ( $ this -> multipleOf !== null && fmod ( ( float ) $ value , ( float ) $ this -> multipleOf ) != 0 ) { //error $ return -> errorObject = new IncorrectParametersException ( [ [ 'type' => static :: getType ( ) , 'failure' => 'multipleOf' ] ] ) ; } else { $ return -> errorObject = null ; //Set status to success $ return -> status = true ; //Type cast $ return -> value = $ this -> cast ( $ value ) ; } return $ return ; }
Validate value, without calling validateCommon
@see \Phramework\Validate\ValidateResult for ValidateResult object
@param  mixed $value Value to validate
@return ValidateResult
Validate value without calling validateCommon