Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
DoctrineSchemaBuilder
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
3 / 3
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
1
 addTable
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getSql
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Wikimedia\Rdbms;
4
5use Doctrine\DBAL\Platforms\AbstractPlatform;
6use Doctrine\DBAL\Schema\Schema;
7
8/**
9 * @experimental
10 * @unstable
11 */
12class DoctrineSchemaBuilder implements SchemaBuilder {
13    use DoctrineAbstractSchemaTrait;
14
15    private Schema $schema;
16    private AbstractPlatform $platform;
17
18    /**
19     * A builder object that take abstract schema definition and produces sql to create the tables.
20     *
21     * @param AbstractPlatform $platform A Doctrine Platform object, Can be Mysql, Sqlite, etc.
22     */
23    public function __construct( AbstractPlatform $platform ) {
24        $this->schema = new Schema();
25        $this->platform = $platform;
26    }
27
28    /**
29     * @inheritDoc
30     */
31    public function addTable( array $schema ) {
32        $this->addTableToSchema( $this->schema, $schema );
33    }
34
35    /**
36     * @inheritDoc
37     */
38    public function getSql() {
39        return $this->schema->toSql( $this->platform );
40    }
41
42}