Code Duplication    Length = 21-21 lines in 2 locations

src/Charcoal/Loader/FileLoader.php 1 location

@@ 172-192 (lines=21) @@
169
     * @param  string $filename A file to search for.
170
     * @return string The full path to the matched file.
171
     */
172
    protected function firstMatchingFilename($filename)
173
    {
174
        if (file_exists($filename)) {
175
            return $filename;
176
        }
177
178
        $paths = $this->paths();
179
180
        if (empty($paths)) {
181
            return null;
182
        }
183
184
        foreach ($paths as $path) {
185
            $file = $path.DIRECTORY_SEPARATOR.$filename;
186
            if (file_exists($file)) {
187
                return $file;
188
            }
189
        }
190
191
        return null;
192
    }
193
194
    /**
195
     * Retrieve all matches from search paths.

src/Charcoal/Model/Service/MetadataLoader.php 1 location

@@ 433-453 (lines=21) @@
430
     * @param  string $filename A supported metadata file.
431
     * @return array|null
432
     */
433
    private function loadFile($filename)
434
    {
435
        if (file_exists($filename)) {
436
            return $this->loadJsonFile($filename);
437
        }
438
439
        $paths = $this->paths();
440
441
        if (empty($paths)) {
442
            return null;
443
        }
444
445
        foreach ($paths as $basePath) {
446
            $file = $basePath.DIRECTORY_SEPARATOR.$filename;
447
            if (file_exists($file)) {
448
                return $this->loadJsonFile($file);
449
            }
450
        }
451
452
        return null;
453
    }
454
455
    /**
456
     * Load the contents of a JSON file.