ConcatenationFileBuilder   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 22
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A buildMigrationFile() 0 18 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Generator;
6
7
use DateTimeImmutable;
8
use DateTimeInterface;
9
use Doctrine\Migrations\Query\Query;
10
use function sprintf;
11
12
/**
13
 * The ConcatenationFileBuilder class is responsible for building a migration SQL file from an array of queries per version.
14
 *
15
 * @internal
16
 */
17
final class ConcatenationFileBuilder implements FileBuilder
18
{
19
    /** @param array<string,Query[]> $queriesByVersion */
20 1
    public function buildMigrationFile(
21
        array $queriesByVersion,
22
        string $direction,
23
        ?DateTimeInterface $now = null
24
    ) : string {
25 1
        $now    = $now ?? new DateTimeImmutable();
26 1
        $string = sprintf("-- Doctrine Migration File Generated on %s\n", $now->format('Y-m-d H:i:s'));
27
28 1
        foreach ($queriesByVersion as $version => $queries) {
29 1
            $string .= "\n-- Version " . $version . "\n";
30
31 1
            foreach ($queries as $query) {
32 1
                $string .= $query->getStatement() . ";\n";
33
            }
34
        }
35
36 1
        return $string;
37
    }
38
}
39