Completed
Push — stable ( 86ecc3...3a45ea )
by Nuno
07:34
created

Migrator::getMigrationFiles()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * This file is part of Laravel Zero.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace LaravelZero\Framework\Components\Database;
13
14
use Symfony\Component\Finder\Finder;
15
use Illuminate\Database\Migrations\Migrator as BaseMigrator;
16
17
/**
18
 * This is the Laravel Zero Framework Database Component Migrator Implementation.
19
 */
20
class Migrator extends BaseMigrator
21
{
22
    /**
23
     * Get all of the migration files in a given path.
24
     *
25
     * Differs from the original `getMigrationFiles` because
26
     * the build feature don't support globs.
27
     *
28
     * @param  string|array  $paths
29
     *
30
     * @return array
31
     */
32
    public function getMigrationFiles($paths)
33
    {
34
        return collect($paths)->flatMap(function ($path) {
35
            return collect((new Finder)->in([$path])->files())->map( function ($file) {
36
                return $file->getPathname();
37
            })->all();
38
        })->filter()->sortBy(function ($file) {
39
            return $this->getMigrationName($file);
40
        })->values()->keyBy(function ($file) {
41
            return $this->getMigrationName($file);
42
        })->all();
43
    }
44
}
45