src/Variables/Specific/AbstractReadOnly.php
protected function cast($value = null, int $type = Variables::TYPE_STRING)
    {
        if ($value === null) {
            return $this->getDefault($type);
        }
        switch ($type) {
            case Variables::TYPE_INT:
                $value = @\intval($value);
                break;
            case Variables::TYPE_FLOAT:
                $value = @\floatval($value);
                break;
            case Variables::TYPE_STRING:
                $value = @\strval($value);
                break;
            case Variables::TYPE_ARRAY:
                $value = (array)$value;
                break;
            case Variables::TYPE_JSON_DECODED:
                $value = @\json_decode(@\strval($value), true, 512) ?: '';
                break;
            case Variables::TYPE_AUTO:
                break;
            default:
                throw new DomainException('Invalid variable type specified');
                break;
        }
        return $value;
    }
protected function cast($value = null, int $type = Variables::TYPE_STRING)
    {
        if ($value === null) {
            return $this->getDefault($type);
        }
        switch ($type) {
            case Variables::TYPE_INT:
                $value = @\intval($value);
                break;
            case Variables::TYPE_FLOAT:
                $value = @\floatval($value);
                break;
            case Variables::TYPE_STRING:
                $value = @\strval($value);
                break;
            case Variables::TYPE_ARRAY:
                $value = (array)$value;
                break;
            case Variables::TYPE_JSON_DECODED:
                $value = @\json_decode(@\strval($value), true, 512) ?: '';
                break;
            case Variables::TYPE_AUTO:
                break;
            default:
                throw new DomainException('Invalid variable type specified');
                break;
        }
        return $value;
    }
protected function cast ( $ value = null , int $ type = Variables :: TYPE_STRING ) { if ( $ value === null ) { return $ this -> getDefault ( $ type ) ; } switch ( $ type ) { case Variables :: TYPE_INT : $ value = @ \ intval ( $ value ) ; break ; case Variables :: TYPE_FLOAT : $ value = @ \ floatval ( $ value ) ; break ; case Variables :: TYPE_STRING : $ value = @ \ strval ( $ value ) ; break ; case Variables :: TYPE_ARRAY : $ value = ( array ) $ value ; break ; case Variables :: TYPE_JSON_DECODED : $ value = @ \ json_decode ( @ \ strval ( $ value ) , true , 512 ) ? : '' ; break ; case Variables :: TYPE_AUTO : break ; default : throw new DomainException ( 'Invalid variable type specified' ) ; break ; } return $ value ; }
Method casting value to specified type. If provided value is null, then default value for specified type will
be returned.

@param null $value
@param int  $type
@return array|float|int|mixed|null|string
Method casting value to specified type . If provided value is null then default value for specified type will be returned .