MigrationVersionService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
/*
3
 * This file is part of the StfalconStudioDoctrineRedisCacheBundle.
4
 *
5
 * (c) Stfalcon LLC <stfalcon.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace StfalconStudio\DoctrineRedisCacheBundle\Service\Migration;
14
15
use Doctrine\Migrations\Finder\MigrationFinder;
16
17
/**
18
 * MigrationVersionService.
19
 *
20
 * @author Artem Henvald <[email protected]>
21
 */
22
class MigrationVersionService
23
{
24
    /** @var string */
25
    private $migrationDirectory;
26
27
    /** @var MigrationFinder */
28
    private $migrationFinder;
29
30
    /**
31
     * @param string          $migrationDirectory
32
     * @param MigrationFinder $migrationFinder
33
     */
34
    public function __construct(string $migrationDirectory, MigrationFinder $migrationFinder)
35
    {
36
        $this->migrationDirectory = $migrationDirectory;
37
        $this->migrationFinder = $migrationFinder;
38
    }
39
40
    /**
41
     * @return string
42
     */
43 View Code Duplication
    public function getLastMigrationVersion(): string
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
        $migrations = $this->migrationFinder->findMigrations($this->migrationDirectory);
46
        $versions = \array_keys($migrations);
47
        $latest = \end($versions);
48
49
        return false !== $latest ? (string) $latest : '0';
50
    }
51
}
52