Code Duplication    Length = 27-27 lines in 2 locations

src/Util/Support/ArraySupport.php 2 locations

@@ 91-117 (lines=27) @@
88
     * @param mixed $value
89
     * @return array
90
     */
91
    public static function set(&$array, $key, $value)
92
    {
93
        $key = static::normalizeKey($key);
94
95
        if ($key === null || $key === '')
96
        {
97
            return ($array = $value);
98
        }
99
100
        $keys = explode('.', $key);
101
        $last = array_pop($keys);
102
        $currentElement =& $array;
103
104
        foreach ($keys as $currentKey)
105
        {
106
            if (!array_key_exists($currentKey, $currentElement) || !is_array($currentElement[$currentKey]))
107
            {
108
                $currentElement[$currentKey] = [];
109
            }
110
111
            $currentElement =& $currentElement[$currentKey];
112
        }
113
114
        $currentElement[$last] = $value;
115
116
        return $array;
117
    }
118
119
    /**
120
     * Remove the value stored under given key from the array with dot notation support.
@@ 126-152 (lines=27) @@
123
     * @param string $key
124
     * @return bool
125
     */
126
    public static function remove(&$array, $key)
127
    {
128
        $key = static::normalizeKey($key);
129
130
        if ($key === null || $key === '')
131
        {
132
            return ($array = []);
133
        }
134
135
        $keys = explode('.', $key);
136
        $last = array_pop($keys);
137
        $currentElement =& $array;
138
139
        foreach ($keys as $currentKey)
140
        {
141
            if (!array_key_exists($currentKey, $currentElement) || !is_array($currentElement[$currentKey]))
142
            {
143
                $currentElement[$currentKey] = [];
144
            }
145
146
            $currentElement =& $currentElement[$currentKey];
147
        }
148
149
        unset($currentElement[$last]);
150
151
        return $array;
152
    }
153
154
    /**
155
     * Flatten a multi-dimensional array into a single level using dot notation.