Passed
Push — main ( af1024...b746de )
by Thierry
02:04
created

TableTrait::tableStatusOrName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 1
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 TableTrait
14
{
15
    /**
16
     * Get table status
17
     *
18
     * @param string $table
19
     * @param bool $fast Return only "Name", "Engine" and "Comment" fields
20
     *
21
     * @return TableEntity|null
22
     */
23
    public function tableStatus(string $table, bool $fast = false)
24
    {
25
        return $this->table->tableStatus($table, $fast);
26
    }
27
28
    /**
29
     * Get all tables statuses
30
     *
31
     * @param bool $fast Return only "Name", "Engine" and "Comment" fields
32
     *
33
     * @return TableEntity[]
34
     */
35
    public function tableStatuses(bool $fast = false)
36
    {
37
        return $this->table->tableStatuses($fast);
38
    }
39
40
    /**
41
     * Get all tables names
42
     *
43
     * @return array
44
     */
45
    public function tableNames()
46
    {
47
        return $this->table->tableNames();
48
    }
49
50
    /**
51
     * Get status of a single table and fall back to name on error
52
     *
53
     * @param string $table
54
     * @param bool $fast Return only "Name", "Engine" and "Comment" fields
55
     *
56
     * @return TableEntity
57
     */
58
    public function tableStatusOrName(string $table, bool $fast = false)
59
    {
60
        return $this->table->tableStatusOrName($table, $fast);
61
    }
62
63
    /**
64
     * Find out whether the identifier is view
65
     *
66
     * @param TableEntity $tableStatus
67
     *
68
     * @return bool
69
     */
70
    public function isView(TableEntity $tableStatus)
71
    {
72
        return $this->table->isView($tableStatus);
73
    }
74
75
    /**
76
     * Check if table supports foreign keys
77
     *
78
     * @param TableEntity $tableStatus
79
     *
80
     * @return bool
81
     */
82
    public function supportForeignKeys(TableEntity $tableStatus)
83
    {
84
        return $this->table->supportForeignKeys($tableStatus);
85
    }
86
87
    /**
88
     * Get information about fields
89
     *
90
     * @param string $table
91
     *
92
     * @return array
93
     */
94
    public function fields(string $table)
95
    {
96
        return $this->table->fields($table);
97
    }
98
99
    /**
100
     * Get table indexes
101
     *
102
     * @param string $table
103
     * @param ConnectionInterface $connection
104
     *
105
     * @return array
106
     */
107
    public function indexes(string $table, ConnectionInterface $connection = null)
108
    {
109
        return $this->table->indexes($table, $connection);
110
    }
111
112
    /**
113
     * Get foreign keys in table
114
     *
115
     * @param string $table
116
     *
117
     * @return array array($name => array("db" => , "ns" => , "table" => , "source" => [], "target" => [], "onDelete" => , "onUpdate" => ))
118
     */
119
    public function foreignKeys(string $table)
120
    {
121
        return $this->table->foreignKeys($table);
122
    }
123
124
    /**
125
     * Get information about a trigger
126
     *
127
     * @param string $name
128
     * @param string $table
129
     *
130
     * @return TriggerEntity
131
     */
132
    public function trigger(string $name, string $table = '')
133
    {
134
        return $this->table->trigger($name, $table);
135
    }
136
137
    /**
138
     * Get defined triggers
139
     *
140
     * @param string $table
141
     *
142
     * @return array
143
     */
144
    public function triggers(string $table)
145
    {
146
        return $this->table->triggers($table);
147
    }
148
149
    /**
150
     * Get trigger options
151
     *
152
     * @return array ("Timing" => [], "Event" => [], "Type" => [])
153
     */
154
    public function triggerOptions()
155
    {
156
        return $this->table->triggerOptions();
157
    }
158
159
    /**
160
     * Get referencable tables with single column primary key except self
161
     *
162
     * @param string $table
163
     *
164
     * @return array
165
     */
166
    public function referencableTables(string $table)
167
    {
168
        return $this->table->referencableTables($table);
169
    }
170
171
    /**
172
     * Get help link for table
173
     *
174
     * @param string $name
175
     *
176
     * @return string relative URL or null
177
     */
178
    public function tableHelp(string $name)
179
    {
180
        return $this->table->tableHelp($name);
181
    }
182
}
183