MenusPlugin   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A subMenus() 0 20 5
1
<?php
2
3
namespace XoopsModules\Xoositemap\Plugin;
4
5
/**
6
 * Xoopartners module
7
 *
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
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
 * @copyright       XOOPS Project (https://xoops.org)
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 * @package         Xoopartners
18
 * @since           2.6.0
19
 * @author          Laurent JEN (Aka DuGris)
20
21
 */
22
class MenusPlugin extends \Xoops\Module\Plugin\PluginAbstract implements \MenusPluginInterface
23
{
24
    /**
25
     * expects an array of array containing:
26
     * name,      Name of the submenu
27
     * url,       Url of the submenu relative to the module
28
     * ex: return array(0 => array(
29
     *      'name' => _MI_PUBLISHER_SUB_SMNAME3;
30
     *      'url' => "search.php";
31
     *    ));
32
     *
33
     * @return array
34
     */
35
    public function subMenus()
36
    {
37
        $ret = [];
38
        if (\Xoops::getInstance()->isModule() && 'xoositemap' == \Xoops::getInstance()->module->getVar('dirname')) {
0 ignored issues
show
Bug introduced by
The method getVar() does not exist on null. ( Ignorable by Annotation )

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

38
        if (\Xoops::getInstance()->isModule() && 'xoositemap' == \Xoops::getInstance()->module->/** @scrutinizer ignore-call */ getVar('dirname')) {

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
39
            $xoops = \Xoops::getInstance();
40
            $helper = \XoopsModules\Xoositemap\Helper::getInstance();
41
            $sitemapConfig = $helper->loadConfig();
0 ignored issues
show
Bug introduced by
The method loadConfig() does not exist on Xoops\Module\Helper\HelperAbstract. It seems like you code against a sub-type of Xoops\Module\Helper\HelperAbstract such as XoopsModules\Xoositemap\Helper. ( Ignorable by Annotation )

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

41
            /** @scrutinizer ignore-call */ 
42
            $sitemapConfig = $helper->loadConfig();
Loading history...
42
43
            $i = 0;
44
            if ($sitemapConfig['xoositemap_main']) {
45
                foreach ($sitemapConfig['xoositemapModule'] as $k => $module) {
46
                    $menu = $xoops->module->getByDirname($module);
0 ignored issues
show
Bug introduced by
The method getByDirname() does not exist on null. ( Ignorable by Annotation )

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

46
                    /** @scrutinizer ignore-call */ 
47
                    $menu = $xoops->module->getByDirname($module);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
47
                    $ret[$i]['name'] = $menu->getVar('name');
48
                    $ret[$i]['url']  = 'index.php?op=' . $module;
49
                    ++$i;
50
                }
51
            }
52
        }
53
54
        return $ret;
55
    }
56
}
57