Completed
Pull Request — master (#949)
by Grégoire
02:40
created

GlobFinder::findMigrations()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 0
Metric Value
cc 2
eloc 5
c 0
b 0
f 0
nc 2
nop 2
dl 0
loc 10
ccs 5
cts 6
cp 0.8333
crap 2.0185
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Finder;
6
7
use function glob;
8
use function rtrim;
9
10
/**
11
 * The GlobFinder class finds migrations in a directory using the PHP glob() function.
12
 */
13
final class GlobFinder extends Finder
14
{
15
    /**
16
     * {@inheritDoc}
17
     */
18 36
    public function findMigrations(string $directory, ?string $namespace = null) : array
19
    {
20 36
        $dir = $this->getRealPath($directory);
21
22 34
        $files = glob(rtrim($dir, '/') . '/Version*.php');
23 34
        if ($files === false) {
24
            $files = [];
25
        }
26
27 34
        return $this->loadMigrations($files, $namespace);
28
    }
29
}
30