Passed
Push — master ( 75056b...85839c )
by Goffy
12:27 queued 09:11
created

Modulemenu   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 22
c 1
b 0
f 0
dl 0
loc 50
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMenuitemsSbadmin5() 0 3 1
A getMenuitemsDefault() 0 34 3
1
<?php
2
3
namespace XoopsModules\Wgsitenotice;
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
 * @copyright    XOOPS Project https://xoops.org/
17
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
18
 * @author       Goffy - XOOPS Development Team
19
 */
20
//\defined('\XOOPS_ROOT_PATH') || die('Restricted access');
21
22
/**
23
 * Class Modulemenu
24
 */
25
class Modulemenu
26
{
27
28
    /** function to create an array for XOOPS main menu
29
     *
30
     * @return array
31
     */
32
    public function getMenuitemsDefault()
33
    {
34
35
        $moduleDirName = \basename(\dirname(__DIR__));
36
        $subcount      = 1;
0 ignored issues
show
Unused Code introduced by
The assignment to $subcount is dead and can be removed.
Loading history...
37
        $pathname      = \XOOPS_ROOT_PATH . '/modules/' . $moduleDirName . '/';
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...
38
        $urlModule     = \XOOPS_URL . '/modules/' . $moduleDirName . '/';
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...
39
40
        require_once $pathname . 'include/common.php';
41
        $helper = \XoopsModules\Wgsitenotice\Helper::getInstance();
42
43
        // start creation of link list as array
44
        $items = [];
45
        // versions
46
        $versionsHandler = $helper->getHandler('Versions');
47
        $version_crit = 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...
48
        $version_crit->setSort('version_weight');
49
        $version_crit->setOrder('ASC');
50
        $version_crit->add(new \Criteria('version_current', '1'));
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...
51
        $versions_rows = $versionsHandler->getCount($version_crit);
52
        $versions_arr = $versionsHandler->getAll($version_crit);
53
54
        if ($versions_rows > 0) {
55
            foreach (\array_keys($versions_arr) as $i)
56
            {
57
                $items[] = [
58
                    'name' => $versions_arr[$i]->getVar('version_name'),
59
                    'url'  =>  $urlModule . 'index.php?version_id=' . $versions_arr[$i]->getVar('version_id'),
60
                ];
61
            }
62
        }
63
        // end creation of link list as array
64
65
        return $items;
66
    }
67
68
    /** function to create a list of nested sublinks
69
     *
70
     * @return array
71
     */
72
    public function getMenuitemsSbadmin5()
73
    {
74
        return $this->getMenuitemsDefault();
75
    }
76
77
78
}
79