Passed
Push — master ( 2ecc51...c1b656 )
by Michael
04:26 queued 02:02
created

b_efqdiralpha1_menu_show()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 29
Code Lines 19

Duplication

Lines 8
Ratio 27.59 %

Importance

Changes 0
Metric Value
cc 3
eloc 19
nc 4
nop 1
dl 8
loc 29
rs 8.8571
c 0
b 0
f 0
1
<?php
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 *
7
 * This program is distributed in the hope that it will be useful,
8
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
/**
13
 * @copyright    {@link https://xoops.org/ XOOPS Project}
14
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later}
15
 * @package      efqdirectory
16
 * @since
17
 * @author       Martijn Hertog (aka wtravel)
18
 * @author       XOOPS Development Team,
19
 */
20
21
/******************************************************************************
22
 * Function: b_efqdiralpha1_menu_show
23
 * Input   : $options[0] = date for the most recent links
24
 *                    hits for the most popular links
25
 *           $block['content'] = The optional above content
26
 *           $options[1]   = How many reviews are displayes
27
 * Output  : Returns the desired most recent or most popular links
28
 *****************************************************************************
29
 * @param $options
30
 * @return array
31
 */
32
33
function b_efqdiralpha1_menu_show($options)
0 ignored issues
show
Unused Code introduced by
The parameter $options is not used and could be removed. ( Ignorable by Annotation )

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

33
function b_efqdiralpha1_menu_show(/** @scrutinizer ignore-unused */ $options)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
34
{
35
    global $xoopsDB, $xoopsModule, $eh;
36
    //  $info = __DIR__;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
37
    //  $split = preg_split("#[\\\]#", $info);
0 ignored issues
show
Unused Code Comprehensibility introduced by
54% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
38
    //  $count = count($split) - 2;
0 ignored issues
show
Unused Code Comprehensibility introduced by
43% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
39
    //  $moddir = $split[$count];
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
40
    //    $moddir = $xoopsModule->getvar("dirname");
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
    $dirname       = basename(dirname(__DIR__));
42
    $moduleHandler = xoops_getHandler('module');
0 ignored issues
show
Bug introduced by
The function xoops_getHandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

42
    $moduleHandler = /** @scrutinizer ignore-call */ xoops_getHandler('module');
Loading history...
43
    $module        = $moduleHandler->getByDirname($dirname);
44
    $moddir        = $module->getvar('dirname');
45
46
    $block                 = array();
47
    $block['lang_dirmenu'] = _MB_EFQDIR_MENU;
48
    $block['moddir']       = $moddir;
49
    $myts                  = MyTextSanitizer::getInstance();
0 ignored issues
show
Bug introduced by
The type MyTextSanitizer 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...
50
    $result                = $xoopsDB->query('SELECT dirid, name, descr FROM ' . $xoopsDB->prefix($module->getVar('dirname', 'n') . '_dir') . " WHERE open='1' ORDER BY name") or $eh->show('0013');
51 View Code Duplication
    while ($myrow = $xoopsDB->fetchArray($result)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
        $directory              = array();
53
        $name                   = $myts->htmlSpecialChars($myrow['name']);
54
        $directory['dirid']     = $myrow['dirid'];
55
        $directory['name']      = $name;
56
        $directory['descr']     = $myrow['descr'];
57
        $block['directories'][] = $directory;
58
    }
59
    $sublink = array();
0 ignored issues
show
Unused Code introduced by
The assignment to $sublink is dead and can be removed.
Loading history...
60
61
    return $block;
62
}
63
64
/**
65
 * @param $options
66
 * @return string
67
 */
68 View Code Duplication
function b_efqdiralpha1_menu_edit($options)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
{
70
    $form = '' . _MB_EFQDIR_DISP . '&nbsp;';
71
    $form .= "<input type='hidden' name='options[]' value='";
72
    if ($options[0] === 'date') {
73
        $form .= "date'";
74
    } else {
75
        $form .= "hits'";
76
    }
77
    $form .= '>';
78
    $form .= "<input type='text' name='options[]' value='" . $options[1] . '\'>&nbsp;' . _MB_EFQDIR_LISTINGS . '';
79
    $form .= '&nbsp;<br>' . _MB_EFQDIR_CHARS . "&nbsp;<input type='text' name='options[]' value='" . $options[2] . '\'>&nbsp;' . _MB_EFQDIR_LENGTH . '';
80
81
    return $form;
82
}
83