SchemaWithNameGenerator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 48
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A createTableObject() 0 6 1
A renameTable() 0 8 1
1
<?php
2
3
namespace RDV\Bundle\MigrationBundle\Migration\Schema;
4
5
use Doctrine\DBAL\DBALException;
6
use Doctrine\DBAL\Schema\SchemaConfig;
7
use Doctrine\DBAL\Schema\Sequence;
8
use RDV\Bundle\MigrationBundle\Tools\DbIdentifierNameGenerator;
9
10
class SchemaWithNameGenerator extends Schema
11
{
12
    const TABLE_CLASS = 'RDV\Bundle\MigrationBundle\Migration\Schema\TableWithNameGenerator';
13
14
    /**
15
     * @var DbIdentifierNameGenerator
16
     */
17
    protected $nameGenerator;
18
19
    /**
20
     * @param DbIdentifierNameGenerator $nameGenerator
21
     * @param Table[]                   $tables
22
     * @param Sequence[]                $sequences
23
     * @param SchemaConfig              $schemaConfig
24
     */
25
    public function __construct(
26
        DbIdentifierNameGenerator $nameGenerator,
27
        array $tables = [],
28
        array $sequences = [],
29
        SchemaConfig $schemaConfig = null
30
    ) {
31
        $this->nameGenerator = $nameGenerator;
32
33
        parent::__construct($tables, $sequences, $schemaConfig);
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    protected function createTableObject(array $args)
40
    {
41
        $args['nameGenerator'] = $this->nameGenerator;
42
43
        return parent::createTableObject($args);
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49
    public function renameTable($oldTableName, $newTableName)
50
    {
51
        throw new DBALException(
52
            "Schema#renameTable() was removed, because it drops and recreates " .
53
            "the table instead. There is no fix available, because a schema diff cannot reliably detect if a " .
54
            "table was renamed or one table was created and another one dropped."
55
        );
56
    }
57
}
58