xooghost_edit()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 37
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 26
nc 3
nop 1
dl 0
loc 37
rs 9.504
c 0
b 0
f 0
1
<?php
2
/**
3
 * Xooghost module
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright       XOOPS Project (https://xoops.org)
13
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
14
 * @package         Xooghost
15
 * @since           2.6.0
16
 * @author          Laurent JEN (Aka DuGris)
17
 *
18
 * @param $options
19
 *
20
 * @return mixed
21
 */
22
function xooghost_show($options)
23
{
24
    $helper = \XoopsModules\Xooghost\Helper::getInstance();
25
    $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

25
    /** @scrutinizer ignore-call */ 
26
    $ghostConfig = $helper->loadConfig();
Loading history...
Unused Code introduced by
The assignment to $ghostConfig is dead and can be removed.
Loading history...
26
    $pageHandler = $helper->getHandler('Page');
27
28
    $helper->xoops()->theme()->addStylesheet('modules/xooghost/assets/css/module.css');
29
    $helper->xoops()->theme()->addStylesheet('modules/xooghost/assets/css/block.css');
30
31
    $block['template'] = $options[0];
0 ignored issues
show
Comprehensibility Best Practice introduced by
$block was never initialized. Although not strictly required by PHP, it is generally a good practice to add $block = array(); before regardless.
Loading history...
32
    $block['pages'] = $pageHandler->getPublished($options[1], $options[2], 0, $options[3]);
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

32
    /** @scrutinizer ignore-call */ 
33
    $block['pages'] = $pageHandler->getPublished($options[1], $options[2], 0, $options[3]);

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...
33
34
    return $block;
35
}
36
37
/**
38
 * @param $options
39
 *
40
 * @return string
41
 */
42
function xooghost_edit($options)
43
{
44
    $helper = \XoopsModules\Xooghost\Helper::getInstance();
45
    $ghostConfig = $helper->loadConfig();
46
47
    $block_form = new \XoopsBlockForm();
0 ignored issues
show
Bug introduced by
The type XoopsBlockForm 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
49
    $display_mode = new \Xoops\Form\Select(_MB_XOO_GHOST_MODE . ' : ', 'options[0]', $options[0]);
50
    $display_mode->addOption('list', _MB_XOO_GHOST_MODE_LIST);
51
    $display_mode->addOption('table', _MB_XOO_GHOST_MODE_TABLE);
52
    $display_mode->addOption('select', _MB_XOO_GHOST_MODE_SELECT);
53
    $block_form->addElement($display_mode);
54
55
    $sort_mode = new \Xoops\Form\Select(_MB_XOO_GHOST_SORT . ' : ', 'options[1]', $options[1]);
56
    $sort_mode->addOption('id', _MB_XOO_GHOST_SORT_ID);
57
    $sort_mode->addOption('published', _MB_XOO_GHOST_SORT_RECENTS);
58
    $sort_mode->addOption('hits', _MB_XOO_GHOST_SORT_HITS);
59
60
    if ('none' !== $ghostConfig['xooghost_rld']['rld_mode']) {
61
        if ('rate' === $ghostConfig['xooghost_rld']['rld_mode']) {
62
            $sort_mode->addOption('rates', _MB_XOO_GHOST_SORT_RATES);
63
        } else {
64
            $sort_mode->addOption('like', _MB_XOO_GHOST_SORT_LIKE);
65
            $sort_mode->addOption('dislike', _MB_XOO_GHOST_SORT_DISLIKE);
66
        }
67
    }
68
    $sort_mode->addOption('random', _MB_XOO_GHOST_SORT_RANDOM);
69
    $block_form->addElement($sort_mode);
70
71
    $order_mode = new \Xoops\Form\Select(_MB_XOO_GHOST_ORDER . ' : ', 'options[2]', $options[2]);
72
    $order_mode->addOption('asc', _MB_XOO_GHOST_ORDER_ASC);
73
    $order_mode->addOption('desc', _MB_XOO_GHOST_ORDER_DESC);
74
    $block_form->addElement($order_mode);
75
76
    $block_form->addElement(new \Xoops\Form\Text(_MB_XOO_GHOST_LIMIT, 'options[3]', 1, 2, $options[3]));
77
78
    return $block_form->render();
79
}
80