package php_serialize import ( "strconv" ) func PhpValueString(p PhpValue) (res string) { res, _ = p.(string) return } func PhpValueBool(p PhpValue) (res bool) { switch v := p.(type) { case bool: res = v case string: res, _ = strconv.ParseBool(v) } return } func PhpValueInt(p PhpValue) (res int) { switch intVal := p.(type) { case int: res = intVal case int8: res = int(intVal) case int16: res = int(intVal) case int32: res = int(intVal) case int64: res = int(intVal) case uint: res = int(intVal) case uint8: res = int(intVal) case uint16: res = int(intVal) case uint32: res = int(intVal) case uint64: res = int(intVal) case string: str, _ := p.(string) res, _ = strconv.Atoi(str) } return } func PhpValueInt64(p PhpValue) (res int64) { switch v := p.(type) { case int64: res = v default: res = int64(PhpValueInt(v)) } return } func PhpValueUInt(p PhpValue) (res uint) { switch v := p.(type) { case uint: res = v default: res = uint(PhpValueInt(v)) } return } func PhpValueUInt64(p PhpValue) (res uint64) { switch v := p.(type) { case uint64: res = v default: res = uint64(PhpValueInt(v)) } return } func PhpValueFloat64(p PhpValue) (res float64) { switch v := p.(type) { case float64: res = v case string: res, _ = strconv.ParseFloat(v, 64) default: return float64(PhpValueInt(p)) } return }