DBALSchemaDiffProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A createFromSchema() 0 4 1
A createToSchema() 0 4 1
A getSqlDiffToMigrate() 0 4 1
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 3
    public function __construct(AbstractSchemaManager $schemaManager, AbstractPlatform $platform)
30
    {
31 3
        $this->schemaManager = $schemaManager;
32 3
        $this->platform      = $platform;
33 3
    }
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