Passed
Pull Request — master (#11)
by Michael
11:08
created

Utility::rmove()   B

Complexity

Conditions 10
Paths 7

Size

Total Lines 29
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 14
c 0
b 0
f 0
nc 7
nop 2
dl 0
loc 29
rs 7.6666

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Xoopsfaq;
6
7
/*
8
 Xoopsfaq Utility Class Definition
9
10
 You may not change or alter any portion of this comment or credits of
11
 supporting developers from this source code or any supporting source code
12
 which is considered copyrighted (c) material of the original comment or credit
13
 authors.
14
15
 This program is distributed in the hope that it will be useful, but
16
 WITHOUT ANY WARRANTY; without even the implied warranty of
17
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18
 */
19
20
/**
21
 * Module:  myQuiz
22
 *
23
 * @package      ::    \module\xoopsfaq\class
24
 * @license      https://www.gnu.org/licenses/gpl-2.0.html GNU Public License
25
 * @copyright    https://xoops.org 2001-2017 &copy; XOOPS Project
26
 * @author       ZySpec <[email protected]>
27
 * @author       Mamba <[email protected]>
28
 * @since        ::      File available since version 4.10
29
 */
30
31
use Xmf\Module\Admin;
32
use XoopsModules\Xoopsfaq\{
33
    Common
34
};
35
36
/**
37
 * Class Utility
38
 */
39
class Utility extends Common\SysUtility
40
{
41
    //--------------- Custom module methods -----------------------------
42
43
    /**
44
     * Render the icon links
45
     *
46
     * @param array $icon_array contains operation=>icon_name as key=>value
47
     * @param mixed $param      HTML parameter
48
     * @param mixed $value      HTML parameter value to set
49
     * @param mixed $extra      are any additional HTML attributes desired for the <a> tag
50
     * @return string
51
     */
52
    public static function renderIconLinks($icon_array = [], $param, $value = null, $extra = null)
53
    {
54
        $moduleDirName = \basename(\dirname(__DIR__));
55
        xoops_loadLanguage('admin', $moduleDirName);
56
        $ret = '';
57
        if (null !== $value) {
58
            foreach ($icon_array as $_op => $icon) {
59
                if (false === \strpos($icon, '.')) {
60
                    $iconName = $icon;
61
                    $iconExt  = 'png';
62
                } else {
63
                    $iconName = \substr($icon, 0, \strlen($icon) - \strrchr($icon, '.'));
64
                    $iconExt  = \substr(\strrchr($icon, '.'), 1);
65
                }
66
                $url = (!\is_numeric($_op)) ? $_op . '?' . $param . '=' . $value : \xoops_getenv('SCRIPT_NAME') . '?op=' . $iconName . '&amp;' . $param . '=' . $value;
67
                if (null !== $extra) {
68
                    $url .= ' ' . $extra;
69
                }
70
                $title = \constant(\htmlspecialchars(mb_strtoupper('_XO_LA_' . $iconName), \ENT_QUOTES | \ENT_HTML5));
71
                $img   = '<img src="' . Admin::iconUrl($iconName . '.' . $iconExt, '16') . '"' . ' title ="' . $title . '"' . ' alt = "' . $title . '"' . ' class="bnone middle">';
72
                $ret   .= '<a href="' . $url . '"' . $extra . '>' . $img . '</a>';
73
            }
74
        }
75
        return $ret;
76
    }
77
78
}
79