Code Duplication    Length = 21-23 lines in 2 locations

src/ConfigFactory.php 2 locations

@@ 56-78 (lines=23) @@
53
            $files = $files[0];
54
        }
55
56
        while (count($files) > 0) {
57
            try {
58
                $file = array_pop($files);
59
60
                if (! is_readable($file)) {
61
                    continue;
62
                }
63
64
                $config = static::createFromArray(
65
                    static::getFromCache($file, function ($file) {
66
                        return Loader::load($file);
67
                    })
68
                );
69
70
                if (null === $config) {
71
                    continue;
72
                }
73
74
                return $config;
75
            } catch (Exception $exception) {
76
                // Fail silently and try next file.
77
            }
78
        }
79
80
        return static::createFromArray([]);
81
    }
@@ 176-196 (lines=21) @@
173
            $files = array_reverse($files[0]);
174
        }
175
176
        while (count($files) > 0) {
177
            try {
178
                $file = array_pop($files);
179
180
                if (! is_readable($file)) {
181
                    continue;
182
                }
183
184
                $new_data = static::getFromCache($file, function ($file) {
185
                    return Loader::load($file);
186
                });
187
188
                if (null === $data) {
189
                    continue;
190
                }
191
192
                $data = array_merge($data, $new_data);
193
            } catch (Exception $exception) {
194
                // Fail silently and try next file.
195
            }
196
        }
197
198
        return static::createFromArray($data);
199
    }