Passed
Push — master ( 95e0c4...fc8ab0 )
by
unknown
44s queued 15s
created

b_suico_lastpictures_edit()   F

Complexity

Conditions 18
Paths 512

Size

Total Lines 57
Code Lines 36

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 36
c 1
b 1
f 0
dl 0
loc 57
rs 1.3777
cc 18
nc 512
nop 1

How to fix   Long Method    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
 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
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
14
/**
15
 * @category        Module
16
 * @package         suico
17
 * @copyright       {@link https://xoops.org/ XOOPS Project}
18
 * @license         GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
19
 * @author          Marcello Brandão aka  Suico, Mamba, LioMJ  <https://xoops.org>
20
 */
21
22
use XoopsModules\Suico;
23
24
if (!defined('XOOPS_ROOT_PATH')) {
25
    exit();
26
}
27
//include_once(XOOPS_ROOT_PATH."/class/criteria.php");
28
//require_once XOOPS_ROOT_PATH . '/modules/suico/class/Image.php';
29
/**
30
 * @param $options
31
 * @return array
32
 */
33
function b_suico_lastpictures_show($options)
34
{
35
    global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
36
    $myts  = MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
37
    $block = [];
38
	
39
    /**
40
     * Criteria for Pictures Block
41
     */
42
    $criteria = new Criteria('image_id', 0, '>');
43
    $criteria->setSort('image_id');
44
    $criteria->setOrder('DESC');
45
    $criteria->setLimit($options[4]);
46
47
	/**
48
     * Creating factories of pictures
49
     */
50
    $imageFactory = new Suico\ImageHandler($xoopsDB);
51
	$block['picture']      = $imageFactory->getLastPicturesForBlock($options[4]);
52
	$block['showtitle']    = $options[0];
53
	$block['showcaption']  = $options[1];
54
 	$block['showdate']     = $options[2];
55
 	$block['showowner']    = $options[3];
56
    return $block;
57
	
58
}
59
60
/**
61
 * @param $options
62
 * @return string
63
 */
64
function b_suico_lastpictures_edit($options)
65
{
66
    $form = _MB_SUICO_SHOWPICTURETITLE . '&nbsp;';
67
    $chk = '';
68
    if (isset($options[0]) && 0 != $options[0]) {
69
        $chk = ' checked';
70
    }
71
    $form .= "<input type='radio' name='options[0]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
72
    $chk  = '';
73
    if (!isset($options[0]) || 0 == $options[0]) {
74
        $chk = ' checked';
75
    }
76
    $form .= "&nbsp;<input type='radio' name='options[0]' value='0'" . $chk . ' >' . _NO . '<br>';
77
78
79
    $form .= _MB_SUICO_SHOWPICTURECAPTION . '&nbsp;';
80
    if (isset($options[1]) && 1 == $options[1]) {
81
        $chk = ' checked';
82
    }
83
    $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
84
    $chk  = '';
85
    if (!isset($options[1]) || 0 == $options[1]) {
86
        $chk = ' checked';
87
    }
88
    $form .= "&nbsp;<input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>';
89
90
	$form .= _MB_SUICO_SHOWPICTUREDATE . '&nbsp;';
91
    if (isset($options[2]) && 1 == $options[2]) {
92
        $chk = ' checked';
93
    }
94
95
96
    $form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
97
    $chk  = '';
98
    if (!isset($options[2]) || 0 == $options[2]) {
99
        $chk = ' checked';
100
    }
101
    $form .= "&nbsp;<input type='radio' name='options[2]' value='0'" . $chk . ' >' . _NO . '<br>';
102
103
104
	$form .= _MB_SUICO_SHOWPICTUREOWNER . '&nbsp;';
105
    if (isset($options[3]) && 1 == $options[3]) {
106
        $chk = ' checked';
107
    }
108
109
110
    $form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' >&nbsp;' . _YES . '';
111
    $chk  = '';
112
    if (!isset($options[3]) || 0 == $options[3]) {
113
        $chk = ' checked';
114
    }
115
    $form .= "&nbsp;<input type='radio' name='options[3]' value='0'" . $chk . ' >' . _NO . '<br>';
116
117
118
	$form .= _MB_SUICO_TOTALPICTUREDISPLAY . '&nbsp;';
119
    $form .= "<input type='text' name='options[4]' value='" . (isset($options[4]) ? $options[4]:0) . "'>";
120
    return $form; 
121
}
122