Passed
Push — master ( ac9a19...e11ae0 )
by Michael
13:36 queued 09:25
created

updateBlock()   B

Complexity

Conditions 11
Paths 18

Size

Total Lines 51
Code Lines 35

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 11
eloc 35
c 1
b 0
f 0
nc 18
nop 9
dl 0
loc 51
rs 7.3166

How to fix   Long Method    Complexity    Many Parameters   

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:

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 declare(strict_types=1);
2
3
/**
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 *
9
 * @category        Module
10
 * @author          XOOPS Development Team
11
 * @copyright       XOOPS Project
12
 * @link            https://xoops.org
13
 * @license         GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
14
 */
15
16
use Xmf\Module\Admin;
17
use Xmf\Request;
18
use XoopsModules\Xoopspoll\{
19
    Common\Blocksadmin,
20
    Common\BlockActionsHandler,
21
    Helper
22
};
23
24
/** @var Admin $adminObject */
25
/** @var Helper $helper */
26
require __DIR__ . '/admin_header.php';
27
xoops_cp_header();
28
29
$moduleDirName      = $helper->getDirname();
30
$moduleDirNameUpper = \mb_strtoupper($moduleDirName);
31
32
$xoopsModule = XoopsModule::getByDirname($moduleDirName);
33
34
if (!is_object($GLOBALS['xoopsUser']) || !is_object($xoopsModule)
35
    || !$GLOBALS['xoopsUser']->isAdmin($xoopsModule->mid())) {
36
    exit(constant('CO_' . $moduleDirNameUpper . '_' . 'ERROR403'));
37
}
38
39
/** @var \XoopsMySQLDatabase $xoopsDB */
40
$xoopsDB       = \XoopsDatabaseFactory::getDatabaseConnection();
41
$xoopsSecurity = new \XoopsSecurity();
42
43
$blocksadmin = new Blocksadmin($xoopsDB, $helper, $xoopsModule, $xoopsSecurity);
44
45
// Call the handleActions method
46
$op = Request::getCmd('op', 'list');
47
48
// Instantiate the BlockActionsHandler
49
$blockActionsHandler = new BlockActionsHandler($blocksadmin);
50
51
// Instantiate the Block DTO
52
$blockData = $blockActionsHandler->processPostData();
53
$blockData->op = $op;
54
$blockActionsHandler->handleActions($blockData);
55
56
    if ('order' === $op) {
57
    $blockActionsHandler->processOrderBlockAction($blockData);
58
    }
59
60
require __DIR__ . '/admin_footer.php';
61