Passed
Branch master (38ab27)
by Michael
03:06
created

TDMCreateTables::getFormTables()   F

Complexity

Conditions 12
Paths 512

Size

Total Lines 104
Code Lines 79

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
cc 12
eloc 79
nc 512
nop 1
dl 0
loc 104
rs 3.0554
c 4
b 0
f 1

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/*
4
 You may not change or alter any portion of this comment or credits
5
 of supporting developers from this source code or any supporting source code
6
 which is considered copyrighted (c) material of the original comment or credit authors.
7
8
 This program is distributed in the hope that it will be useful,
9
 but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * tdmcreate module.
15
 *
16
 * @copyright       XOOPS Project (https://xoops.org)
17
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
18
 *
19
 * @since           2.5.7
20
 *
21
 * @author          Txmod Xoops <[email protected]> - <http://www.txmodxoops.org/>
22
 *
23
 * @version         $Id: 1.91 tables.php 11297 2013-03-24 10:58:10Z timgno $
24
 */
25
include __DIR__.'/autoload.php';
26
27
/**
28
 * Class TDMCreateTables.
29
 */
30
class TDMCreateTables extends XoopsObject
0 ignored issues
show
Bug introduced by
The type XoopsObject was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
31
{
32
    /**
33
     * Options.
34
     */
35
    public $options = [
36
        'install',
37
        'index',
38
        'blocks',
39
        'admin',
40
        'user',
41
        'submenu',
42
        'submit',
43
        'tag',
44
        'broken',
45
        'search',
46
        'comments',
47
        'notifications',
48
        'permissions',
49
        'rate',
50
        'print',
51
        'pdf',
52
        'rss',
53
        'single',
54
        'visit',
55
    ];
56
57
    /**
58
    *  @public function constructor class
59
    *  @param null
60
    */
61
62
    public function __construct()
63
    {
64
        $this->initVar('table_id', XOBJ_DTYPE_INT);
0 ignored issues
show
Bug introduced by
The constant XOBJ_DTYPE_INT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
65
        $this->initVar('table_mid', XOBJ_DTYPE_INT);
66
        $this->initVar('table_category', XOBJ_DTYPE_INT);
67
        $this->initVar('table_name', XOBJ_DTYPE_TXTBOX);
0 ignored issues
show
Bug introduced by
The constant XOBJ_DTYPE_TXTBOX was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
68
        $this->initVar('table_solename', XOBJ_DTYPE_TXTBOX);
69
        $this->initVar('table_fieldname', XOBJ_DTYPE_TXTBOX);
70
        $this->initVar('table_nbfields', XOBJ_DTYPE_INT);
71
        $this->initVar('table_order', XOBJ_DTYPE_INT);
72
        $this->initVar('table_image', XOBJ_DTYPE_TXTBOX);
73
        $this->initVar('table_autoincrement', XOBJ_DTYPE_INT);
74
        $this->initVar('table_install', XOBJ_DTYPE_INT);
75
        $this->initVar('table_index', XOBJ_DTYPE_INT);
76
        $this->initVar('table_blocks', XOBJ_DTYPE_INT);
77
        $this->initVar('table_admin', XOBJ_DTYPE_INT);
78
        $this->initVar('table_user', XOBJ_DTYPE_INT);
79
        $this->initVar('table_submenu', XOBJ_DTYPE_INT);
80
        $this->initVar('table_submit', XOBJ_DTYPE_INT);
81
        $this->initVar('table_tag', XOBJ_DTYPE_INT);
82
        $this->initVar('table_broken', XOBJ_DTYPE_INT);
83
        $this->initVar('table_search', XOBJ_DTYPE_INT);
84
        $this->initVar('table_comments', XOBJ_DTYPE_INT);
85
        $this->initVar('table_notifications', XOBJ_DTYPE_INT);
86
        $this->initVar('table_permissions', XOBJ_DTYPE_INT);
87
        $this->initVar('table_rate', XOBJ_DTYPE_INT);
88
        $this->initVar('table_print', XOBJ_DTYPE_INT);
89
        $this->initVar('table_pdf', XOBJ_DTYPE_INT);
90
        $this->initVar('table_rss', XOBJ_DTYPE_INT);
91
        $this->initVar('table_single', XOBJ_DTYPE_INT);
92
        $this->initVar('table_visit', XOBJ_DTYPE_INT);
93
    }
94
95
    /**
96
     * @param string $method
97
     * @param array  $args
98
     *
99
     * @return mixed
100
     */
101
    public function __call($method, $args)
102
    {
103
        $arg = isset($args[0]) ? $args[0] : null;
104
105
        return $this->getVar($method, $arg);
106
    }
107
108
    /**
109
    *  @static function getInstance
110
    *  @param null
111
     * @return TDMCreateTables
112
     */
113
    public static function getInstance()
114
    {
115
        static $instance = false;
116
        if (!$instance) {
117
            $instance = new self();
118
        }
119
120
        return $instance;
121
    }
122
123
    /**
124
    *  @static function getFormTables
125
    *  @param mixed $action
126
     *
127
     * @return XoopsThemeForm
128
     */
129
    public function getFormTables($action = false)
130
    {
131
        if (false === $action) {
132
            $action = $_SERVER['REQUEST_URI'];
133
        }
134
        $tdmcreate = TDMCreateHelper::getInstance();
135
        $isNew = $this->isNew();
136
        $tableName = $this->getVar('table_name');
137
        $tableMid = $this->getVar('table_mid');
138
        $title = $isNew ? sprintf(_AM_TDMCREATE_TABLE_NEW) : sprintf(_AM_TDMCREATE_TABLE_EDIT);
139
140
        xoops_load('XoopsFormLoader');
0 ignored issues
show
Bug introduced by
The function xoops_load was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

140
        /** @scrutinizer ignore-call */ 
141
        xoops_load('XoopsFormLoader');
Loading history...
141
        $form = new XoopsThemeForm($title, 'tableform', $action, 'post', true);
0 ignored issues
show
Bug introduced by
The type XoopsThemeForm was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
142
        $form->setExtra('enctype="multipart/form-data"');
143
144
        $modules = $tdmcreate->getHandler('modules')->getObjects(null);
145
        $modulesSelect = new XoopsFormSelect(_AM_TDMCREATE_TABLE_MODULES, 'table_mid', $tableMid);
0 ignored issues
show
Bug introduced by
The type XoopsFormSelect was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
146
        $modulesSelect->addOption('', _AM_TDMCREATE_TABLE_MODSELOPT);
147
        foreach ($modules as $mod) {
148
            $modulesSelect->addOption($mod->getVar('mod_id'), $mod->getVar('mod_name'));
149
        }
150
        $form->addElement($modulesSelect, true);
151
152
        $tableNameText = new XoopsFormText(_AM_TDMCREATE_TABLE_NAME, 'table_name', 40, 150, $tableName);
0 ignored issues
show
Bug introduced by
The type XoopsFormText was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
153
        $tableNameText->setDescription(_AM_TDMCREATE_TABLE_NAME_DESC);
154
        $form->addElement($tableNameText, true);
155
156
        $tableSoleNameText = new XoopsFormText(_AM_TDMCREATE_TABLE_SOLENAME, 'table_solename', 40, 150, $this->getVar('table_solename'));
157
        $tableSoleNameText->setDescription(_AM_TDMCREATE_TABLE_SOLENAME_DESC);
158
        $form->addElement($tableSoleNameText, true);
159
160
        $radioCategory = $isNew ? 0 : $this->getVar('table_category');
161
        $category = new XoopsFormRadioYN(_AM_TDMCREATE_TABLE_CATEGORY, 'table_category', $radioCategory);
0 ignored issues
show
Bug introduced by
The type XoopsFormRadioYN was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
162
        $category->setDescription(_AM_TDMCREATE_TABLE_CATEGORY_DESC);
163
        $form->addElement($category);
164
165
        $tableFieldname = new XoopsFormText(_AM_TDMCREATE_TABLE_FIELDNAME, 'table_fieldname', 30, 50, $this->getVar('table_fieldname'));
166
        $tableFieldname->setDescription(_AM_TDMCREATE_TABLE_FIELDNAME_DESC);
167
        $form->addElement($tableFieldname);
168
169
        $tableNumbFileds = new XoopsFormText(_AM_TDMCREATE_TABLE_NBFIELDS, 'table_nbfields', 10, 25, $this->getVar('table_nbfields'));
170
        $tableNumbFileds->setDescription(_AM_TDMCREATE_TABLE_NBFIELDS_DESC);
171
        $form->addElement($tableNumbFileds, true);
172
173
        if (!$isNew) {
174
            $tableOrder = new XoopsFormText(_AM_TDMCREATE_TABLE_ORDER, 'table_order', 5, 10, $this->getVar('table_order'));
175
            $tableOrder->setDescription(_AM_TDMCREATE_TABLE_ORDER_DESC);
176
            $form->addElement($tableOrder, true);
177
        }
178
179
        $getTableImage = $this->getVar('table_image');
180
        $tableImage = $getTableImage ?: 'blank.gif';
181
        $icons32Directory = '/Frameworks/moduleclasses/icons/32';
182
        $uploadsDirectory = '/uploads/tdmcreate/images/tables';
183
        $iconsDirectory = is_dir(XOOPS_ROOT_PATH.$icons32Directory) ? $icons32Directory : $uploadsDirectory;
0 ignored issues
show
Bug introduced by
The constant XOOPS_ROOT_PATH was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
184
185
        $imgtray1 = new XoopsFormElementTray(_AM_TDMCREATE_TABLE_IMAGE, '<br>');
0 ignored issues
show
Bug introduced by
The type XoopsFormElementTray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
186
        $imgpath1 = sprintf(_AM_TDMCREATE_FORMIMAGE_PATH, ".{$iconsDirectory}/");
187
        $imageSelect1 = new XoopsFormSelect($imgpath1, 'table_image', $tableImage, 10);
188
        $imageArray1 = XoopsLists::getImgListAsArray(XOOPS_ROOT_PATH.$iconsDirectory);
0 ignored issues
show
Bug introduced by
The type XoopsLists was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
189
        foreach ($imageArray1 as $image1) {
190
            $imageSelect1->addOption("{$image1}", $image1);
191
        }
192
        $imageSelect1->setExtra("onchange='showImgSelected(\"image1\", \"table_image\", \"".$iconsDirectory.'", "", "'.XOOPS_URL."\")'");
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
193
        $imgtray1->addElement($imageSelect1, false);
194
        $imgtray1->addElement(new XoopsFormLabel('', "<br><img src='".XOOPS_URL.'/'.$iconsDirectory.'/'.$tableImage."' name='image1' id='image1' alt='' />"));
0 ignored issues
show
Bug introduced by
The type XoopsFormLabel was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
195
        $fileseltray1 = new XoopsFormElementTray('', '<br>');
196
        $fileseltray1->addElement(new XoopsFormFile(_AM_TDMCREATE_FORMUPLOAD, 'attachedfile', $tdmcreate->getConfig('maxsize')));
0 ignored issues
show
Bug introduced by
The type XoopsFormFile was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
197
        $fileseltray1->addElement(new XoopsFormLabel(''));
198
        $imgtray1->addElement($fileseltray1);
199
        $imgtray1->setDescription(_AM_TDMCREATE_TABLE_IMAGE_DESC);
200
        $form->addElement($imgtray1);
201
202
        $tableAutoincrement = $this->isNew() ? 1 : $this->getVar('table_autoincrement');
203
        $checkTableAutoincrement = new XoopsFormRadioYN(_AM_TDMCREATE_TABLE_AUTO_INCREMENT, 'table_autoincrement', $tableAutoincrement);
204
        $checkTableAutoincrement->setDescription(_AM_TDMCREATE_TABLE_AUTO_INCREMENT_DESC);
205
        $form->addElement($checkTableAutoincrement);
206
207
        $optionsTray = new XoopsFormElementTray(_OPTIONS, '<br>');
0 ignored issues
show
Bug introduced by
The constant _OPTIONS was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
208
209
        $tableCheckAll = new XoopsFormCheckBox('', 'tablebox', 1);
0 ignored issues
show
Bug introduced by
The type XoopsFormCheckBox was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
210
        $tableCheckAll->addOption('allbox', _AM_TDMCREATE_TABLE_ALL);
211
        $tableCheckAll->setExtra(' onclick="xoopsCheckAll(\'tableform\', \'tablebox\');" ');
212
        $tableCheckAll->setClass('xo-checkall');
213
        $optionsTray->addElement($tableCheckAll);
214
        // Options
215
        $checkbox = new XoopsFormCheckbox(' ', 'table_option', $this->getOptionsTables(), '<br>');
0 ignored issues
show
Bug introduced by
The type XoopsFormCheckbox was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
216
        $checkbox->setDescription(_AM_TDMCREATE_OPTIONS_DESC);
217
        foreach ($this->options as $option) {
218
            $checkbox->addOption($option, self::getDefinedLanguage('_AM_TDMCREATE_TABLE_'.strtoupper($option)));
219
        }
220
        $optionsTray->addElement($checkbox);
221
222
        $optionsTray->setDescription(_AM_TDMCREATE_TABLE_OPTIONS_CHECKS_DESC);
223
224
        $form->addElement($optionsTray);
225
226
        $buttonTray = new XoopsFormElementTray(_REQUIRED.' <sup class="red bold">*</sup>', '');
0 ignored issues
show
Bug introduced by
The constant _REQUIRED was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
227
        $buttonTray->addElement(new XoopsFormHidden('op', 'save'));
0 ignored issues
show
Bug introduced by
The type XoopsFormHidden was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
228
        $buttonTray->addElement(new XoopsFormHidden('table_id', ($isNew ? 0 : $this->getVar('table_id'))));
229
        $buttonTray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
0 ignored issues
show
Bug introduced by
The constant _SUBMIT was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
Bug introduced by
The type XoopsFormButton was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
230
        $form->addElement($buttonTray);
231
232
        return $form;
233
    }
234
235
    /**
236
     * Get Values.
237
     *
238
     * @param null $keys
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $format is correct as it would always require null to be passed?
Loading history...
Documentation Bug introduced by
Are you sure the doc-type for parameter $keys is correct as it would always require null to be passed?
Loading history...
Documentation Bug introduced by
Are you sure the doc-type for parameter $maxDepth is correct as it would always require null to be passed?
Loading history...
239
     * @param null $format
240
     * @param null $maxDepth
241
     *
242
     * @return array
243
     */
244
    public function getValuesTables($keys = null, $format = null, $maxDepth = null)
245
    {
246
        $ret = $this->getValues($keys, $format, $maxDepth);
247
        // Values
248
        $ret['id'] = $this->getVar('table_id');
249
        $ret['mid'] = $this->getVar('table_mid');
250
        $ret['name'] = ucfirst($this->getVar('table_name'));
251
        $ret['image'] = $this->getVar('table_image');
252
        $ret['nbfields'] = $this->getVar('table_nbfields');
253
        $ret['order'] = $this->getVar('table_order');
254
        $ret['blocks'] = $this->getVar('table_blocks');
255
        $ret['admin'] = $this->getVar('table_admin');
256
        $ret['user'] = $this->getVar('table_user');
257
        $ret['submenu'] = $this->getVar('table_submenu');
258
        $ret['search'] = $this->getVar('table_search');
259
        $ret['comments'] = $this->getVar('table_comments');
260
        $ret['notifications'] = $this->getVar('table_notifications');
261
        $ret['permissions'] = $this->getVar('table_permissions');
262
263
        return $ret;
264
    }
265
266
    /**
267
     * Get Options.
268
     *
269
     * @return array
270
     */
271
    public function getOptionsTables()
272
    {
273
        $retTable = [];
274
        foreach ($this->options as $option) {
275
            if (1 == $this->getVar('table_' . $option)) {
276
                array_push($retTable, $option);
277
            }
278
        }
279
280
        return $retTable;
281
    }
282
283
    /**
284
     * Get Defined Language.
285
     *
286
     * @param $lang
287
     *
288
     * @return string
289
     */
290
    private static function getDefinedLanguage($lang)
291
    {
292
        if (defined($lang)) {
293
            return constant($lang);
294
        }
295
296
        return $lang;
297
    }
298
}
299
300
/**
301
 *  @Class TDMCreateTablesHandler
302
 *  @extends XoopsPersistableObjectHandler
303
 */
304
class TDMCreateTablesHandler extends XoopsPersistableObjectHandler
0 ignored issues
show
Bug introduced by
The type XoopsPersistableObjectHandler was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
305
{
306
    /**
307
     *  @public function constructor class
308
     *
309
     * @param null|XoopsDatabase $db
310
     */
311
    public function __construct(XoopsDatabase $db)
0 ignored issues
show
Bug introduced by
The type XoopsDatabase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
312
    {
313
        parent::__construct($db, 'tdmcreate_tables', 'TDMCreateTables', 'table_id', 'table_name');
314
    }
315
316
    /**
317
     * @param bool $isNew
318
     *
319
     * @return object
320
     */
321
    public function create($isNew = true)
322
    {
323
        return parent::create($isNew);
324
    }
325
326
    /**
327
     * retrieve a field.
328
     *
329
     * @param int  $i      field id
330
     * @param null $fields
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fields is correct as it would always require null to be passed?
Loading history...
331
     *
332
     * @return mixed reference to the <a href='psi_element://TDMCreateFields'>TDMCreateFields</a> object
333
     *               object
334
     */
335
    public function get($i = null, $fields = null)
336
    {
337
        return parent::get($i, $fields);
338
    }
339
340
    /**
341
     * get inserted id.
342
     *
343
     * @param null
344
     *
345
     * @return int reference to the {@link TDMCreateTables} object
346
     */
347
    public function getInsertId()
348
    {
349
        return $this->db->getInsertId();
350
    }
351
352
    /**
353
     * Get Count Modules.
354
     *
355
     * @param int    $start
356
     * @param int    $limit
357
     * @param string $sort
358
     * @param string $order
359
     *
360
     * @return int
361
     */
362
    public function getCountTables($start = 0, $limit = 0, $sort = 'table_id ASC, table_name', $order = 'ASC')
363
    {
364
        $crCountTables = new CriteriaCompo();
0 ignored issues
show
Bug introduced by
The type CriteriaCompo was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
365
        $crCountTables = $this->getTablesCriteria($crCountTables, $start, $limit, $sort, $order);
366
367
        return $this->getCount($crCountTables);
368
    }
369
370
    /**
371
     * Get All Modules.
372
     *
373
     * @param int    $start
374
     * @param int    $limit
375
     * @param string $sort
376
     * @param string $order
377
     *
378
     * @return array
379
     */
380
    public function getAllTables($start = 0, $limit = 0, $sort = 'table_id ASC, table_name', $order = 'ASC')
381
    {
382
        $crAllTables = new CriteriaCompo();
383
        $crAllTables = $this->getTablesCriteria($crAllTables, $start, $limit, $sort, $order);
384
385
        return $this->getAll($crAllTables);
386
    }
387
388
    /**
389
     * Get All Tables By Module Id.
390
     *
391
     * @param        $modId
392
     * @param int    $start
393
     * @param int    $limit
394
     * @param string $sort
395
     * @param string $order
396
     *
397
     * @return array
398
     */
399
    public function getAllTablesByModuleId($modId, $start = 0, $limit = 0, $sort = 'table_order ASC, table_id, table_name', $order = 'ASC')
400
    {
401
        $crAllTablesByModuleId = new CriteriaCompo();
402
        $crAllTablesByModuleId->add(new Criteria('table_mid', $modId));
0 ignored issues
show
Bug introduced by
The type Criteria was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
403
        $crAllTablesByModuleId = $this->getTablesCriteria($crAllTablesByModuleId, $start, $limit, $sort, $order);
404
405
        return $this->getAll($crAllTablesByModuleId);
406
    }
407
408
    /**
409
     * Get Tables Criteria.
410
     *
411
     * @param $crTables
412
     * @param $start
413
     * @param $limit
414
     * @param $sort
415
     * @param $order
416
     *
417
     * @return mixed
418
     */
419
    private function getTablesCriteria($crTables, $start, $limit, $sort, $order)
420
    {
421
        $crTables->setStart($start);
422
        $crTables->setLimit($limit);
423
        $crTables->setSort($sort);
424
        $crTables->setOrder($order);
425
426
        return $crTables;
427
    }
428
}
429