CreateTableFields::getTableTables()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 7
nc 1
nop 3
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php namespace XoopsModules\Tdmcreate\Files;
2
3
use XoopsModules\Tdmcreate;
4
use XoopsModules\Tdmcreate\Files;
5
6
/*
7
 You may not change or alter any portion of this comment or credits
8
 of supporting developers from this source code or any supporting source code
9
 which is considered copyrighted (c) material of the original comment or credit authors.
10
11
 This program is distributed in the hope that it will be useful,
12
 but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 */
15
/**
16
 * tdmcreate module.
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
20
 *
21
 * @since           2.5.0
22
 *
23
 * @author          Txmod Xoops http://www.txmodxoops.org
24
 *
25
 * @version         $Id: TDMCreateTableFields.php 12258 2014-01-02 09:33:29Z timgno $
26
 */
27
28
/**
29
 * Class CreateTableFields
30
 */
31
class CreateTableFields extends  Files\CreateAbstractClass
32
{
33
    /**
34
     * @public   function constructor
35
     */
36
    public function __construct()
37
    {
38
    }
39
40
    /**
41
     * @static function getInstance
42
     *
43
     * @return bool|\TDMCreateTableFields
0 ignored issues
show
Bug introduced by
The type TDMCreateTableFields 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...
44
     */
45
    public static function getInstance()
46
    {
47
        static $instance = false;
48
        if (!$instance) {
49
            $instance = new self();
50
        }
51
52
        return $instance;
53
    }
54
55
    /**
56
     * @public function getTableTables
57
     *
58
     * @param        $mId
59
     *
60
     * @param string $sort
61
     * @param string $order
62
     * @return mixed
63
     */
64
    public function getTableTables($mId, $sort = 'table_id ASC, table_name', $order = 'ASC')
65
    {
66
        $criteria = new \CriteriaCompo();
67
        $criteria->add(new \Criteria('table_mid', $mId)); // $mId = module Id
68
        $criteria->setSort($sort);
69
        $criteria->setOrder($order);
70
        $tables = Tdmcreate\Helper::getInstance()->getHandler('tables')->getObjects($criteria);
0 ignored issues
show
Bug introduced by
The method getObjects() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of said class. However, the method does not exist in XoopsRankHandler or XoUserHandler. Are you sure you never get one of those? ( Ignorable by Annotation )

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

70
        $tables = Tdmcreate\Helper::getInstance()->getHandler('tables')->/** @scrutinizer ignore-call */ getObjects($criteria);
Loading history...
71
        unset($criteria);
72
73
        return $tables;
74
    }
75
76
    /**
77
     * @public function getTableFields
78
     *
79
     * @param        $mId
80
     * @param        $tId
81
     *
82
     * @param string $sort
83
     * @param string $order
84
     * @return mixed
85
     */
86
    public function getTableFields($mId, $tId, $sort = 'field_id ASC, field_name', $order = 'ASC')
87
    {
88
        $criteria = new \CriteriaCompo();
89
        $criteria->add(new \Criteria('field_mid', $mId)); // $mId = module Id
90
        $criteria->add(new \Criteria('field_tid', $tId)); // $tId = table Id
91
        $criteria->setSort($sort);
92
        $criteria->setOrder($order);
93
        $fields = Tdmcreate\Helper::getInstance()->getHandler('fields')->getObjects($criteria);
94
        unset($criteria);
95
96
        return $fields;
97
    }
98
99
    /**
100
     * @public function getTableFieldElements
101
     *
102
     * @param        $mId
103
     * @param        $tId
104
     *
105
     * @param string $sort
106
     * @param string $order
107
     * @return mixed
108
     */
109
    public function getTableFieldElements($mId = null, $tId = null, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC')
110
    {
111
        $criteria = new \CriteriaCompo();
112
        if (null != $mId) {
113
            $criteria->add(new \Criteria('fieldelement_mid', $mId)); // $mId = module Id
114
            $criteria->setSort($sort);
115
            $criteria->setOrder($order);
116
        }
117
        if (null != $tId) {
118
            $criteria->add(new \Criteria('fieldelement_tid', $tId)); // $tId = table Id
119
            $criteria->setSort($sort);
120
            $criteria->setOrder($order);
121
        }
122
        $fieldElements = Tdmcreate\Helper::getInstance()->getHandler('fieldelements')->getObjects($criteria);
123
        unset($criteria);
124
125
        return $fieldElements;
126
    }
127
128
    /**
129
     * @public function getTableMoreFiles
130
     *
131
     * @param        $mId
132
     *
133
     * @param string $sort
134
     * @param string $order
135
     * @return mixed
136
     */
137
    public function getTableMoreFiles($mId, $sort = 'file_id ASC, file_name', $order = 'ASC')
138
    {
139
        $criteria = new \CriteriaCompo();
140
        $criteria->add(new \Criteria('file_mid', $mId)); // $mId = module Id
141
        $criteria->setSort($sort);
142
        $criteria->setOrder($order);
143
        $morefiles = Tdmcreate\Helper::getInstance()->getHandler('morefiles')->getObjects($criteria);
144
        unset($criteria);
145
146
        return $morefiles;
147
    }
148
}
149