gal_getWysiwygForm()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 12
nc 1
nop 8
dl 0
loc 16
rs 9.8666
c 1
b 0
f 0

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
/**
4
 * ExtGallery functions
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
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 *
13
 * @copyright   {@link https://xoops.org/ XOOPS Project}
14
 * @license     GNU GPL 2 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
15
 * @author      Zoullou (http://www.zoullou.net)
16
 * @package     ExtGallery
17
 * @param $option
18
 * @return bool
19
 */
20
function gal_getmoduleoption($option)
21
{
22
    global $xoopsModuleConfig, $xoopsModule;
23
    static $tbloptions = [];
24
    if (is_array($tbloptions) && array_key_exists($option, $tbloptions)) {
25
        return $tbloptions[$option];
26
    }
27
28
    $retval = false;
29
    if (isset($xoopsModuleConfig)
30
        && (is_object($xoopsModule) && 'extgallery' === $xoopsModule->getVar('dirname')
31
            && $xoopsModule->getVar('isactive'))) {
32
        if (isset($xoopsModuleConfig[$option])) {
33
            $retval = $xoopsModuleConfig[$option];
34
        }
35
    } else {
36
        /** @var \XoopsModuleHandler $moduleHandler */
37
        $moduleHandler = xoops_getHandler('module');
38
        $module        = $moduleHandler->getByDirname('extgallery');
39
40
        /** @var \XoopsModuleHandler $moduleHandler */
41
        /** @var \XoopsConfigHandler $configHandler */
42
        $configHandler = xoops_getHandler('config');
43
        if ($module) {
44
            $moduleConfig = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
45
            if (isset($moduleConfig[$option])) {
46
                $retval = $moduleConfig[$option];
47
            }
48
        }
49
    }
50
    $tbloptions[$option] = $retval;
51
52
    return $retval;
53
}
54
55
/**
56
 * @param $caption
57
 * @param $name
58
 * @param $value
59
 * @param $rows
60
 * @param $cols
61
 * @param $width
62
 * @param $height
63
 * @param $supplemental
64
 *
65
 * @return bool|\XoopsFormEditor
66
 */
67
function gal_getWysiwygForm($caption, $name, $value, $rows, $cols, $width, $height, $supplemental)
0 ignored issues
show
Unused Code introduced by
The parameter $supplemental 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

67
function gal_getWysiwygForm($caption, $name, $value, $rows, $cols, $width, $height, /** @scrutinizer ignore-unused */ $supplemental)

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...
68
{
69
    $editor_option            = mb_strtolower(gal_getmoduleoption('form_options'));
0 ignored issues
show
Bug introduced by
gal_getmoduleoption('form_options') of type boolean is incompatible with the type string expected by parameter $string of mb_strtolower(). ( Ignorable by Annotation )

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

69
    $editor_option            = mb_strtolower(/** @scrutinizer ignore-type */ gal_getmoduleoption('form_options'));
Loading history...
70
    $editor                   = false;
0 ignored issues
show
Unused Code introduced by
The assignment to $editor is dead and can be removed.
Loading history...
71
    $editor_configs           = [];
72
    $editor_configs['name']   = $name;
73
    $editor_configs['value']  = $value;
74
    $editor_configs['rows']   = $rows;
75
    $editor_configs['cols']   = $cols;
76
    $editor_configs['width']  = $width;
77
    $editor_configs['height'] = $height;
78
    $editor_configs['editor'] = $editor_option;
79
80
    $editor = new \XoopsFormEditor($caption, $name, $editor_configs);
81
82
    return $editor;
83
}
84