Passed
Push — main ( b7dd48...48bb0f )
by Thierry
01:28
created

DatabaseTrait::createTable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Lagdo\DbAdmin\Driver;
4
5
use Lagdo\DbAdmin\Driver\Entity\ConfigEntity;
6
use Lagdo\DbAdmin\Driver\Entity\TableEntity;
7
use Lagdo\DbAdmin\Driver\Entity\ForeignKeyEntity;
8
use Lagdo\DbAdmin\Driver\Entity\TriggerEntity;
9
use Lagdo\DbAdmin\Driver\Entity\RoutineEntity;
10
11
use Lagdo\DbAdmin\Driver\Db\ConnectionInterface;
12
13
trait DatabaseTrait
14
{
15
    /**
16
     * Create table
17
     *
18
     * @param TableEntity $tableAttrs
19
     *
20
     * @return bool
21
     */
22
    public function createTable(TableEntity $tableAttrs)
23
    {
24
        return $this->database->createTable($tableAttrs);
25
    }
26
27
    /**
28
     * Alter table
29
     *
30
     * @param string $table
31
     * @param TableEntity $tableAttrs
32
     *
33
     * @return bool
34
     */
35
    public function alterTable(string $table, TableEntity $tableAttrs)
36
    {
37
        return $this->database->alterTable($table, $tableAttrs);
38
    }
39
40
    /**
41
     * Alter indexes
42
     *
43
     * @param string $table Escaped table name
44
     * @param array $alter  Indexes to alter. Array of IndexEntity.
45
     * @param array $drop   Indexes to drop. Array of IndexEntity.
46
     *
47
     * @return bool
48
     */
49
    public function alterIndexes(string $table, array $alter, array $drop)
50
    {
51
        return $this->database->alterIndexes($table, $alter, $drop);
52
    }
53
54
    /**
55
     * Get tables list
56
     *
57
     * @return array
58
     */
59
    public function tables()
60
    {
61
        return $this->database->tables();
62
    }
63
64
    /**
65
     * Get sequences list
66
     *
67
     * @return array
68
     */
69
    public function sequences()
70
    {
71
        return $this->database->sequences();
72
    }
73
74
    /**
75
     * Count tables in all databases
76
     *
77
     * @param array $databases
78
     *
79
     * @return array
80
     */
81
    public function countTables(array $databases)
82
    {
83
        return $this->database->countTables($databases);
84
    }
85
86
    /**
87
     * Drop views
88
     *
89
     * @param array $views
90
     *
91
     * @return bool
92
     */
93
    public function dropViews(array $views)
94
    {
95
        return $this->database->dropViews($views);
96
    }
97
98
    /**
99
     * Truncate tables
100
     *
101
     * @param array $tables
102
     *
103
     * @return bool
104
     */
105
    public function truncateTables(array $tables)
106
    {
107
        return $this->database->truncateTables($tables);
108
    }
109
110
    /**
111
     * Drop tables
112
     *
113
     * @param array $tables
114
     *
115
     * @return bool
116
     */
117
    public function dropTables(array $tables)
118
    {
119
        return $this->database->dropTables($tables);
120
    }
121
122
    /**
123
     * Move tables to other schema
124
     *
125
     * @param array $tables
126
     * @param array $views
127
     * @param string $target
128
     *
129
     * @return bool
130
     */
131
    public function moveTables(array $tables, array $views, string $target)
132
    {
133
        return $this->database->moveTables($tables, $views, $target);
134
    }
135
136
    /**
137
     * Copy tables to other schema
138
     *
139
     * @param array $tables
140
     * @param array $views
141
     * @param string $target
142
     *
143
     * @return bool
144
     */
145
    public function copyTables(array $tables, array $views, string $target)
146
    {
147
        return $this->database->copyTables($tables, $views, $target);
148
    }
149
150
    /**
151
     * Get user defined types
152
     *
153
     * @return array
154
     */
155
    public function userTypes()
156
    {
157
        return $this->database->userTypes();
158
    }
159
160
    /**
161
     * Get existing schemas
162
     *
163
     * @return array
164
     */
165
    public function schemas()
166
    {
167
        return $this->database->schemas();
168
    }
169
170
    /**
171
     * Get events
172
     *
173
     * @return array
174
     */
175
    public function events()
176
    {
177
        return $this->database->events();
178
    }
179
180
    /**
181
     * Get information about stored routine
182
     *
183
     * @param string $name
184
     * @param string $type "FUNCTION" or "PROCEDURE"
185
     *
186
     * @return RoutineEntity
187
     */
188
    public function routine(string $name, string $type)
189
    {
190
        return $this->database->routine($name, $type);
191
    }
192
193
    /**
194
     * Get list of routines
195
     *
196
     * @return array
197
     */
198
    public function routines()
199
    {
200
        return $this->database->routines();
201
    }
202
}
203