CreateTableFields   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 116
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 39
dl 0
loc 116
rs 10
c 0
b 0
f 0
wmc 9

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getInstance() 0 8 2
A getTableFields() 0 11 1
A getTableTables() 0 10 1
A getTableFieldElements() 0 17 3
A getTableMoreFiles() 0 10 1
A __construct() 0 2 1
1
<?php
2
3
namespace XoopsModules\Tdmcreate\Files;
4
5
use XoopsModules\Tdmcreate;
6
use XoopsModules\Tdmcreate\Files;
7
8
/*
9
 You may not change or alter any portion of this comment or credits
10
 of supporting developers from this source code or any supporting source code
11
 which is considered copyrighted (c) material of the original comment or credit authors.
12
13
 This program is distributed in the hope that it will be useful,
14
 but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
 */
17
/**
18
 * tdmcreate module.
19
 *
20
 * @copyright       XOOPS Project (https://xoops.org)
21
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
22
 *
23
 * @since           2.5.0
24
 *
25
 * @author          Txmod Xoops http://www.txmodxoops.org
26
 *
27
 */
28
29
/**
30
 * Class CreateTableFields
31
 */
32
class CreateTableFields extends Files\CreateAbstractClass
33
{
34
    /**
35
     * @public   function constructor
36
     */
37
    public function __construct()
38
    {
39
    }
40
41
    /**
42
     * @static function getInstance
43
     *
44
     * @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...
45
     */
46
    public static function getInstance()
47
    {
48
        static $instance = false;
49
        if (!$instance) {
50
            $instance = new self();
51
        }
52
53
        return $instance;
54
    }
55
56
    /**
57
     * @public function getTableTables
58
     *
59
     * @param        $mId
60
     *
61
     * @param string $sort
62
     * @param string $order
63
     * @return mixed
64
     */
65
    public function getTableTables($mId, $sort = 'table_id ASC, table_name', $order = 'ASC')
66
    {
67
        $criteria = new \CriteriaCompo();
68
        $criteria->add(new \Criteria('table_mid', $mId)); // $mId = module Id
69
        $criteria->setSort($sort);
70
        $criteria->setOrder($order);
71
        $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

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