Code Duplication    Length = 25-25 lines in 2 locations

src/Helper.php 1 location

@@ 22-46 (lines=25) @@
19
     * @param array $b array to be merged from
20
     * @return array the merged array
21
     */
22
    public static function mergeConfig($a, $b)
23
    {
24
        $args = func_get_args();
25
        $res = array_shift($args);
26
        foreach ($args as $items) {
27
            if (!is_array($items)) {
28
                continue;
29
            }
30
            foreach ($items as $k => $v) {
31
                if (is_int($k)) {
32
                    if (isset($res[$k])) {
33
                        $res[] = $v;
34
                    } else {
35
                        $res[$k] = $v;
36
                    }
37
                } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) {
38
                    $res[$k] = self::mergeConfig($res[$k], $v);
39
                } else {
40
                    $res[$k] = $v;
41
                }
42
            }
43
        }
44
45
        return $res;
46
    }
47
48
    /**
49
     * Dumps closure object to string.

src/Plugin.php 1 location

@@ 185-209 (lines=25) @@
182
     * @param array $b array to be merged from
183
     * @return array the merged array
184
     */
185
    public static function mergeConfig($a, $b)
186
    {
187
        $args = func_get_args();
188
        $res = array_shift($args);
189
        foreach ($args as $items) {
190
            if (!is_array($items)) {
191
                continue;
192
            }
193
            foreach ($items as $k => $v) {
194
                if (is_int($k)) {
195
                    if (isset($res[$k])) {
196
                        $res[] = $v;
197
                    } else {
198
                        $res[$k] = $v;
199
                    }
200
                } elseif (is_array($v) && isset($res[$k]) && is_array($res[$k])) {
201
                    $res[$k] = self::mergeConfig($res[$k], $v);
202
                } else {
203
                    $res[$k] = $v;
204
                }
205
            }
206
        }
207
208
        return $res;
209
    }
210
211
    /**
212
     * Read extra config.