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

FileMigrationInformation   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 34
ccs 0
cts 16
cp 0
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getName() 0 4 1
A getId() 0 4 1
A loadMigrationFile() 0 4 1
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