Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PHPUnit\TextUI\XmlConfiguration;
11
 
12
use function array_key_exists;
13
use function sprintf;
14
use function version_compare;
15
 
16
/**
17
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
18
 */
19
final class MigrationBuilder
20
{
21
    private const AVAILABLE_MIGRATIONS = [
22
        '8.5' => [
23
            RemoveLogTypes::class,
24
        ],
25
 
26
        '9.2' => [
27
            RemoveCacheTokensAttribute::class,
28
            IntroduceCoverageElement::class,
29
            MoveAttributesFromRootToCoverage::class,
30
            MoveAttributesFromFilterWhitelistToCoverage::class,
31
            MoveWhitelistDirectoriesToCoverage::class,
32
            MoveWhitelistExcludesToCoverage::class,
33
            RemoveEmptyFilter::class,
34
            CoverageCloverToReport::class,
35
            CoverageCrap4jToReport::class,
36
            CoverageHtmlToReport::class,
37
            CoveragePhpToReport::class,
38
            CoverageTextToReport::class,
39
            CoverageXmlToReport::class,
40
            ConvertLogTypes::class,
41
            UpdateSchemaLocationTo93::class,
42
        ],
43
    ];
44
 
45
    /**
46
     * @throws MigrationBuilderException
47
     */
48
    public function build(string $fromVersion): array
49
    {
50
        if (!array_key_exists($fromVersion, self::AVAILABLE_MIGRATIONS)) {
51
            throw new MigrationBuilderException(
52
                sprintf(
53
                    'Migration from schema version %s is not supported',
54
                    $fromVersion
55
                )
56
            );
57
        }
58
 
59
        $stack = [];
60
 
61
        foreach (self::AVAILABLE_MIGRATIONS as $version => $migrations) {
62
            if (version_compare($version, $fromVersion, '<')) {
63
                continue;
64
            }
65
 
66
            foreach ($migrations as $migration) {
67
                $stack[] = new $migration;
68
            }
69
        }
70
 
71
        return $stack;
72
    }
73
}