Completed
Push — master ( b31514...603a9f )
by Changwan
06:16
created

FileMigrationInformation::loadMigrationFile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Database\Migrator;
3
4
use SplFileInfo;
5
use Wandu\Database\Migrator\Contracts\MigrationInformation;
6
7
class FileMigrationInformation implements MigrationInformation
8
{
9
    /** @var \SplFileInfo */
10
    protected $fileInfo;
11
12
    /**
13
     * @param \SplFileInfo $fileInfo
14
     */
15
    public function __construct(SplFileInfo $fileInfo)
16
    {
17
        $this->fileInfo = $fileInfo;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function getName(): string
24
    {
25
        return substr($this->fileInfo->getFilename(), 14, -4);
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function getId(): string
32
    {
33
        return substr($this->fileInfo->getFilename(), 0, 13);
34
    }
35
36
    public function loadMigrationFile()
37
    {
38
        require_once $this->fileInfo->__toString();
39
    }
40
}
41