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\Xooghost\Plugin;
4
5
/**
6
 * Xooghost 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         Xooghost
18
 * @since           2.6.0
19
 * @author          Laurent JEN (Aka DuGris)
20
 */
21
22
/**
23
 * Class XooghostMenusPlugin
24
 */
25
class MenusPlugin extends \Xoops\Module\Plugin\PluginAbstract implements \MenusPluginInterface
26
{
27
    /**
28
     * expects an array of array containing:
29
     * name,      Name of the submenu
30
     * url,       Url of the submenu relative to the module
31
     * ex: return array(0 => array(
32
     *      'name' => _MI_PUBLISHER_SUB_SMNAME3;
33
     *      'url' => "search.php";
34
     *    ));
35
     *
36
     * @return array
37
     */
38
    public function subMenus()
39
    {
40
        $ret = [];
41
        if (\Xoops::getInstance()->isModule() && 'xooghost' === \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

41
        if (\Xoops::getInstance()->isModule() && 'xooghost' === \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...
42
            $helper = \XoopsModules\Xooghost\Helper::getInstance();
43
            $ghostConfig = $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\Xooghost\Helper. ( Ignorable by Annotation )

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

43
            /** @scrutinizer ignore-call */ 
44
            $ghostConfig = $helper->loadConfig();
Loading history...
44
            $pageHandler = $helper->getHandler('Page');
45
46
            $i = 0;
47
            if ($ghostConfig['xooghost_main']) {
48
                $pages = $pageHandler->getPublished();
0 ignored issues
show
Bug introduced by
The method getPublished() does not exist on XoopsObjectHandler. ( Ignorable by Annotation )

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

48
                /** @scrutinizer ignore-call */ 
49
                $pages = $pageHandler->getPublished();

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...
49
                foreach ($pages as $page) {
50
                    $ret[$i]['name'] = $page['xooghost_title'];
51
                    $ret[$i]['url'] = $page['xooghost_url'];
52
                    ++$i;
53
                }
54
            }
55
        }
56
57
        return $ret;
58
    }
59
}
60