Passed
Push — master ( 229462...d74785 )
by Andreas
02:20 queued 14s
created

DBALSchemaDiffProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Migrations\Provider;
6
7
use Doctrine\DBAL\Platforms\AbstractPlatform;
8
use Doctrine\DBAL\Schema\AbstractSchemaManager;
9
use Doctrine\DBAL\Schema\Schema;
10
11
/**
12
 * The SchemaDiffProvider class is responsible for providing a Doctrine\DBAL\Schema\Schema instance that
13
 * represents the current state of your database. A clone of this Schema instance is passed to each of your migrations
14
 * so that you can manipulate the Schema object. Your manipulated Schema object is then compared to the original Schema
15
 * object to produce the SQL statements that need to be executed.
16
 *
17
 * @internal
18
 *
19
 * @see Doctrine\Migrations\Version\DbalExecutor
20
 */
21
class DBALSchemaDiffProvider implements SchemaDiffProvider
22
{
23
    /** @var AbstractPlatform */
24
    private $platform;
25
26
    /** @var AbstractSchemaManager */
27
    private $schemaManager;
28
29 2
    public function __construct(AbstractSchemaManager $schemaManager, AbstractPlatform $platform)
30
    {
31 2
        $this->schemaManager = $schemaManager;
32 2
        $this->platform      = $platform;
33 2
    }
34
35 2
    public function createFromSchema() : Schema
36
    {
37 2
        return $this->schemaManager->createSchema();
38
    }
39
40 1
    public function createToSchema(Schema $fromSchema) : Schema
41
    {
42 1
        return clone $fromSchema;
43
    }
44
45
    /** @return string[] */
46 1
    public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema) : array
47
    {
48 1
        return $fromSchema->getMigrateToSql($toSchema, $this->platform);
49
    }
50
}
51