b_marquee_smartsection()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 38
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 26
c 0
b 0
f 0
nc 3
nop 3
dl 0
loc 38
rs 9.1928
1
<?php declare(strict_types=1);
2
/**
3
 * ****************************************************************************
4
 * marquee - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard (https://www.herve-thouzard.com)
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 *
14
 * @copyright         Hervé Thouzard (https://www.herve-thouzard.com)
15
 * @license           GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author            Hervé Thouzard (https://www.herve-thouzard.com)
17
 *
18
 * Version :
19
 */
20
21
/*
22
 * @param $limit
23
 * @param $dateFormat
24
 * @param $itemsSize
25
 *
26
 * @return array|bool
27
 */
28
29
// Script to list recent articles from the Smartsection module (tested with Smartsection 2.1)
30
function b_marquee_smartsection($limit, $dateFormat, $itemsSize)
0 ignored issues
show
Unused Code introduced by
The parameter $dateFormat 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

30
function b_marquee_smartsection($limit, /** @scrutinizer ignore-unused */ $dateFormat, $itemsSize)

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...
31
{
32
33
    if (!class_exists('XoopsModules\Smartsection\Helper')) {
34
        return false;
35
    }
36
//    require_once XOOPS_ROOT_PATH . '/modules/smartsection/include/common.php';
37
38
    $block = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $block is dead and can be removed.
Loading history...
39
40
    xoops_load('xoopsuserutility');
41
    $myts                    = \MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
42
    $smartModule             = smartsection_getModuleInfo();
0 ignored issues
show
Unused Code introduced by
The assignment to $smartModule is dead and can be removed.
Loading history...
Bug introduced by
The function smartsection_getModuleInfo 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
    $smartModule             = /** @scrutinizer ignore-call */ smartsection_getModuleInfo();
Loading history...
43
    $block                   = [];
44
    $categoryid              = -1;
45
    $sort                    = 'datesub';
46
    $order                   = XoopsModules\Smartsection\Utility::getOrderBy($sort);
0 ignored issues
show
Bug introduced by
The type XoopsModules\Smartsection\Utility 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...
47
    $smartsectionItemHandler = XoopsModules\Smartsection\Helper::getInstance()->getHandler('Item');
0 ignored issues
show
Bug introduced by
The type XoopsModules\Smartsection\Helper 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...
48
    $itemsObj                = $smartsectionItemHandler->getAllPublished($limit, 0, $categoryid, $sort, $order);
49
    $totalItems              = count($itemsObj);
50
    if ($itemsObj) {
51
        for ($i = 0; $i < $totalItems; ++$i) {
52
            if ($itemsSize > 0) {
53
                $title = xoops_substr($itemsObj[$i]->title(), 0, $itemsSize + 3);
54
            } else {
55
                $title = $itemsObj[$i]->title();
56
            }
57
            $block[] = [
58
                'date'     => $itemsObj[$i]->datesub(),
59
                'category' => $itemsObj[$i]->getCategoryName(),
60
                'author'   => \XoopsUserUtility::getUnameFromId($itemsObj[$i]->uid()),
61
                'title'    => $title,
62
                'link'     => "<a href='" . XOOPS_URL . '/modules/smartsection/item.php?itemid=' . $itemsObj[$i]->itemid() . "'>" . $title . '</a>',
63
            ];
64
        }
65
    }
66
67
    return $block;
68
}
69