ModulesHandler::getInsertId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace XoopsModules\Modulebuilder;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * modules class.
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
20
 *
21
 * @since           2.5.7
22
 *
23
 * @author          Txmod Xoops <[email protected]> - <https://xoops.org/>
24
 *
25
 */
26
27
/**
28
 * @Class ModulesHandler
29
 * @extends \XoopsPersistableObjectHandler
30
 */
31
class ModulesHandler extends \XoopsPersistableObjectHandler
32
{
33
    /**
34
     * @public function constructor class
35
     *
36
     * @param null|\XoopsDatabase|\XoopsMySQLDatabase $db
37
     */
38
    public function __construct(\XoopsDatabase $db)
39
    {
40
        parent::__construct($db, 'modulebuilder_modules', Modules::class, 'mod_id', 'mod_name');
41
    }
42
43
    /**
44
     * @param bool $isNew
45
     *
46
     * @return \XoopsObject
47
     */
48
    public function create($isNew = true)
49
    {
50
        return parent::create($isNew);
51
    }
52
53
    /**
54
     * retrieve a field.
55
     *
56
     * @param int  $i field id
57
     * @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...
58
     *
59
     * @return mixed reference to the <a href='psi_element://Fields'>Fields</a> object
60
     *               object
61
     */
62
    public function get($i = null, $fields = null)
63
    {
64
        return parent::get($i, $fields);
65
    }
66
67
    /**
68
     * get inserted id.
69
     *
70
     * @param null
71
     *
72
     * @return int reference to the {@link Tables} object
73
     */
74
    public function getInsertId()
75
    {
76
        return $this->db->getInsertId();
77
    }
78
79
    /**
80
     * Get Count Modules.
81
     *
82
     * @param int    $start
83
     * @param int    $limit
84
     * @param string $sort
85
     * @param string $order
86
     *
87
     * @return int
88
     */
89
    public function getCountModules($start = 0, $limit = 0, $sort = 'mod_id', $order = 'DESC')
90
    {
91
        $crCountModules = new \CriteriaCompo();
92
        $crCountModules = $this->getModulesCriteria($crCountModules, $start, $limit, $sort, $order);
93
94
        return $this->getCount($crCountModules);
95
    }
96
97
    /**
98
     * Get All Modules.
99
     *
100
     * @param int    $start
101
     * @param int    $limit
102
     * @param string $sort
103
     * @param string $order
104
     *
105
     * @return array
106
     */
107
    public function getAllModules($start = 0, $limit = 0, $sort = 'mod_id', $order = 'DESC')
108
    {
109
        $crAllModules = new \CriteriaCompo();
110
        $crAllModules = $this->getModulesCriteria($crAllModules, $start, $limit, $sort, $order);
111
112
        return $this->getAll($crAllModules);
113
    }
114
115
    /**
116
     * Get Modules Criteria.
117
     *
118
     * @param $crModules
119
     * @param $start
120
     * @param $limit
121
     * @param $sort
122
     * @param $order
123
     *
124
     * @return mixed
125
     */
126
    private function getModulesCriteria($crModules, $start, $limit, $sort, $order)
127
    {
128
        $crModules->setStart($start);
129
        $crModules->setLimit($limit);
130
        $crModules->setSort($sort);
131
        $crModules->setOrder($order);
132
133
        return $crModules;
134
    }
135
}
136