b_marquee_news()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 26
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 18
c 0
b 0
f 0
nc 2
nop 3
dl 0
loc 26
rs 9.6666
1
<?php declare(strict_types=1);
2
3
/**
4
 * ****************************************************************************
5
 * marquee - MODULE FOR XOOPS
6
 * Copyright (c) Hervé Thouzard (https://www.herve-thouzard.com)
7
 *
8
 * You may not change or alter any portion of this comment or credits
9
 * of supporting developers from this source code or any supporting source code
10
 * which is considered copyrighted (c) material of the original comment or credit authors.
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
 *
15
 * @copyright         Hervé Thouzard (https://www.herve-thouzard.com)
16
 * @license           GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
17
 * @author            Hervé Thouzard (https://www.herve-thouzard.com)
18
 *
19
 * Version :
20
 * ****************************************************************************
21
 *
22
 * @param $limit
23
 * @param $dateFormat
24
 * @param $itemsSize
25
 *
26
 * @return array
27
 */
28
29
use XoopsModules\News;
0 ignored issues
show
Bug introduced by
The type XoopsModules\News 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...
30
31
// Script to list recent articles from the News module (version >=1.21)
32
/**
33
 * @param $limit
34
 * @param $dateFormat
35
 * @param $itemsSize
36
 * @return array
37
 */
38
function b_marquee_news($limit, $dateFormat, $itemsSize)
39
{
40
    //    require_once XOOPS_ROOT_PATH . '/modules/marquee/class/Utility.php';
41
    require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php';
42
    $block      = $stories = [];
0 ignored issues
show
Unused Code introduced by
The assignment to $stories is dead and can be removed.
Loading history...
43
    $story      = new News\NewsStory();
0 ignored issues
show
Unused Code introduced by
The assignment to $story is dead and can be removed.
Loading history...
Bug introduced by
The type XoopsModules\News\NewsStory 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...
44
    $restricted = News\Utility::getModuleOption('restrictindex', 'news');
0 ignored issues
show
Bug introduced by
The type XoopsModules\News\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...
45
    $stories    = News\NewsStory::getAllPublished($limit, 0, $restricted, 0, 1, true, 'published');
46
    if (count($stories) > 0) {
47
        foreach ($stories as $onestory) {
48
            if ($itemsSize > 0) {
49
                $title = xoops_substr($onestory->title(), 0, $itemsSize + 3);
50
            } else {
51
                $title = $onestory->title();
52
            }
53
            $block[] = [
54
                'date'     => formatTimestamp($onestory->published(), $dateFormat),
55
                'category' => $onestory->topic_title(),
56
                'author'   => $onestory->uid(),
57
                'title'    => $title,
58
                'link'     => "<a href='" . XOOPS_URL . '/modules/news/article.php?storyid=' . $onestory->storyid() . "'>" . $title . '</a>',
59
            ];
60
        }
61
    }
62
63
    return $block;
64
}
65