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 getTableFields() 0 11 1
A getTableTables() 0 10 1
A getInstance() 0 8 2
A __construct() 0 2 1
A getTableFieldelements() 0 17 3
A getTableMorefiles() 0 10 1
1
<?php
2
3
namespace XoopsModules\Modulebuilder\Files;
4
5
use XoopsModules\Modulebuilder;
6
use XoopsModules\Modulebuilder\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
 * modulebuilder module.
19
 *
20
 * @copyright       XOOPS Project (https://xoops.org)
21
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
22
 *
23
 * @since           2.5.0
24
 *
25
 * @author          Txmod Xoops https://xoops.org 
26
 *                  Goffy https://myxoops.org
27
 *
28
 */
29
30
/**
31
 * Class CreateTableFields
32
 */
33
class CreateTableFields extends Files\CreateAbstractClass
34
{
35
    /**
36
     * @public   function constructor
37
     */
38
    public function __construct()
39
    {
40
    }
41
42
    /**
43
     * @static function getInstance
44
     *
45
     * @return bool|\ModuleBuilderTableFields
0 ignored issues
show
Bug introduced by
The type ModuleBuilderTableFields 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...
46
     */
47
    public static function getInstance()
48
    {
49
        static $instance = false;
50
        if (!$instance) {
51
            $instance = new self();
52
        }
53
54
        return $instance;
55
    }
56
57
    /**
58
     * @public function getTableTables
59
     *
60
     * @param        $mId
61
     *
62
     * @param string $sort
63
     * @param string $order
64
     * @return mixed
65
     */
66
    public function getTableTables($mId, $sort = 'table_id ASC, table_name', $order = 'ASC')
67
    {
68
        $criteria = new \CriteriaCompo();
69
        $criteria->add(new \Criteria('table_mid', $mId)); // $mId = module Id
70
        $criteria->setSort($sort);
71
        $criteria->setOrder($order);
72
        $tables = Modulebuilder\Helper::getInstance()->getHandler('Tables')->getObjects($criteria);
73
        unset($criteria);
74
75
        return $tables;
76
    }
77
78
    /**
79
     * @public function getTableFields
80
     *
81
     * @param        $mId
82
     * @param        $tId
83
     *
84
     * @param string $sort
85
     * @param string $order
86
     * @return mixed
87
     */
88
    public function getTableFields($mId, $tId, $sort = 'field_order ASC, field_id', $order = 'ASC')
89
    {
90
        $criteria = new \CriteriaCompo();
91
        $criteria->add(new \Criteria('field_mid', $mId)); // $mId = module Id
92
        $criteria->add(new \Criteria('field_tid', $tId)); // $tId = table Id
93
        $criteria->setSort($sort);
94
        $criteria->setOrder($order);
95
        $fields = Modulebuilder\Helper::getInstance()->getHandler('Fields')->getObjects($criteria);
96
        unset($criteria);
97
98
        return $fields;
99
    }
100
101
    /**
102
     * @public function getTableFieldelements
103
     *
104
     * @param        $mId
105
     * @param        $tId
106
     *
107
     * @param string $sort
108
     * @param string $order
109
     * @return mixed
110
     */
111
    public function getTableFieldelements($mId = null, $tId = null, $sort = 'fieldelement_id ASC, fieldelement_name', $order = 'ASC')
112
    {
113
        $criteria = new \CriteriaCompo();
114
        if (null != $mId) {
115
            $criteria->add(new \Criteria('fieldelement_mid', $mId)); // $mId = module Id
116
            $criteria->setSort($sort);
117
            $criteria->setOrder($order);
118
        }
119
        if (null != $tId) {
120
            $criteria->add(new \Criteria('fieldelement_tid', $tId)); // $tId = table Id
121
            $criteria->setSort($sort);
122
            $criteria->setOrder($order);
123
        }
124
        $fieldElements = Modulebuilder\Helper::getInstance()->getHandler('Fieldelements')->getObjects($criteria);
125
        unset($criteria);
126
127
        return $fieldElements;
128
    }
129
130
    /**
131
     * @public function getTableMorefiles
132
     *
133
     * @param        $mId
134
     *
135
     * @param string $sort
136
     * @param string $order
137
     * @return mixed
138
     */
139
    public function getTableMorefiles($mId, $sort = 'file_id ASC, file_name', $order = 'ASC')
140
    {
141
        $criteria = new \CriteriaCompo();
142
        $criteria->add(new \Criteria('file_mid', $mId)); // $mId = module Id
143
        $criteria->setSort($sort);
144
        $criteria->setOrder($order);
145
        $morefiles = Modulebuilder\Helper::getInstance()->getHandler('Morefiles')->getObjects($criteria);
146
        unset($criteria);
147
148
        return $morefiles;
149
    }
150
}
151