-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp_value_read.v
More file actions
82 lines (68 loc) · 1.81 KB
/
Copy pathphp_value_read.v
File metadata and controls
82 lines (68 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
module vphp
pub fn (v PhpValue) value_at(key string) PhpValue {
return PhpValue.from_zval(v.to_zval().value_at(key))
}
pub fn (v PhpValue) value(key string) !PhpValue {
out := v.value_at(key)
if !out.is_valid() || out.is_undef() {
return error('key "${key}" not found')
}
return out
}
pub fn (v PhpValue) property_exists(name string) bool {
if obj := v.as_object() {
return obj.property_exists(name)
}
return false
}
pub fn (v PhpValue) prop_value(name string) PhpValue {
if obj := v.as_object() {
return obj.prop_value(name)
}
return PhpValue.null()
}
pub fn (v PhpValue) call_method(method string, args ...PhpArgInput) PhpValue {
if obj := v.as_object() {
return obj.call_method(method, ...args)
}
return PhpValue.null()
}
pub fn (v PhpValue) [] (key string) PhpValue {
return v.value_at(key)
}
pub fn (v PhpValue) string_at(key string, default_value string) string {
return v.to_zval().string_at(key, default_value)
}
pub fn (v PhpValue) raw_string_at(key string, default_value string) string {
return v.to_zval().raw_string_at(key, default_value)
}
pub fn (v PhpValue) int_at(key string, default_value int) int {
return v.to_zval().int_at(key, default_value)
}
pub fn (v PhpValue) bool_at(key string, default_value bool) bool {
return v.to_zval().bool_at(key, default_value)
}
pub fn (v PhpValue) count() int {
if arr := v.as_array() {
return arr.count()
}
return 0
}
pub fn (v PhpValue) index_value(index int) PhpValue {
if arr := v.as_array() {
return arr.index_value(index)
}
return PhpValue.null()
}
pub fn (v PhpValue) to_string_list() []string {
if arr := v.as_array() {
return arr.to_string_list()
}
return v.to_zval().to_string_list()
}
pub fn (v PhpValue) to_string_map() map[string]string {
if arr := v.as_array() {
return arr.to_string_map()
}
return v.to_zval().to_string_map()
}