2
2
3
3
namespace RocketTheme \Toolbox \ArrayTraits ;
4
4
5
+ use function is_array ;
6
+ use function is_object ;
7
+
5
8
/**
6
9
* Implements nested ArrayAccess interface with dot notation.
7
10
*
@@ -30,9 +33,9 @@ public function get($name, $default = null, $separator = null)
30
33
$ current = $ this ->items ;
31
34
32
35
foreach ($ path as $ field ) {
33
- if (\ is_object ($ current ) && isset ($ current ->{$ field })) {
36
+ if (is_object ($ current ) && isset ($ current ->{$ field })) {
34
37
$ current = $ current ->{$ field };
35
- } elseif (\ is_array ($ current ) && isset ($ current [$ field ])) {
38
+ } elseif (is_array ($ current ) && isset ($ current [$ field ])) {
36
39
$ current = $ current [$ field ];
37
40
} else {
38
41
return $ default ;
@@ -58,15 +61,15 @@ public function set($name, $value, $separator = null)
58
61
$ current = &$ this ->items ;
59
62
60
63
foreach ($ path as $ field ) {
61
- if (\ is_object ($ current )) {
64
+ if (is_object ($ current )) {
62
65
// Handle objects.
63
66
if (!isset ($ current ->{$ field })) {
64
67
$ current ->{$ field } = [];
65
68
}
66
69
$ current = &$ current ->{$ field };
67
70
} else {
68
71
// Handle arrays and scalars.
69
- if (!\ is_array ($ current )) {
72
+ if (!is_array ($ current )) {
70
73
$ current = [$ field => []];
71
74
} elseif (!isset ($ current [$ field ])) {
72
75
$ current [$ field ] = [];
@@ -104,15 +107,15 @@ public function undef($name, $separator = null)
104
107
$ current = &$ this ->items ;
105
108
106
109
foreach ($ path as $ field ) {
107
- if (\ is_object ($ current )) {
110
+ if (is_object ($ current )) {
108
111
// Handle objects.
109
112
if (!isset ($ current ->{$ field })) {
110
113
return $ this ;
111
114
}
112
115
$ current = &$ current ->{$ field };
113
116
} else {
114
117
// Handle arrays and scalars.
115
- if (!\ is_array ($ current ) || !isset ($ current [$ field ])) {
118
+ if (!is_array ($ current ) || !isset ($ current [$ field ])) {
116
119
return $ this ;
117
120
}
118
121
$ current = &$ current [$ field ];
0 commit comments