Failed Conditions
Pull Request — master (#632)
by Michael
02:44
created

SchemaDiffProvider   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A createToSchema() 0 3 1
A createFromSchema() 0 3 1
A getSqlDiffToMigrate() 0 3 1
A __construct() 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
class SchemaDiffProvider implements SchemaDiffProviderInterface
12
{
13
    /** @var AbstractPlatform */
14
    private $platform;
15
16
    /** @var AbstractSchemaManager */
17
    private $schemaManager;
18
19 121
    public function __construct(AbstractSchemaManager $schemaManager, AbstractPlatform $platform)
20
    {
21 121
        $this->schemaManager = $schemaManager;
22 121
        $this->platform      = $platform;
23 121
    }
24
25 13
    public function createFromSchema() : Schema
26
    {
27 13
        return $this->schemaManager->createSchema();
28
    }
29
30 13
    public function createToSchema(Schema $fromSchema) : Schema
31
    {
32 13
        return clone $fromSchema;
33
    }
34
35
    /** @return string[] */
36 13
    public function getSqlDiffToMigrate(Schema $fromSchema, Schema $toSchema) : array
37
    {
38 13
        return $fromSchema->getMigrateToSql($toSchema, $this->platform);
39
    }
40
}
41