Smartsection::grabEntries()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 16
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 21
rs 9.7333
1
<?php
2
3
declare(strict_types=1);
4
5
namespace XoopsModules\Rssfit\Plugins;
6
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
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
 */
16
17
/**
18
 * @copyright    XOOPS Project (https://xoops.org)
19
 * @license      GNU GPL 2 or later (https://www.gnu.org/licenses/gpl-2.0.html)
20
 * @package      RSSFit - Extendable XML news feed generator
21
 * @author       NS Tai (aka tuff) <http://www.brandycoke.com>
22
 * @author       XOOPS Development Team
23
 */
24
25
/*
26
* About this RSSFit plug-in
27
* Author: tuff <http://www.brandycoke.com>
28
* Requirements (Tested with):
29
*  Module: SmartSection <http://www.smartfactory.ca>
30
*  Version: 1.0.4 Beta 2 / 1.1 Beta 1 / 1.05 Beta 1
31
*  RSSFit verision: 1.2 / 1.5
32
*  XOOPS version: 2.0.13.2 / 2.2.3
33
*/
34
35
use XoopsModules\Smartsection\{
36
    Helper as SmartsectionHelper
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...
37
};
38
39
if (!\defined('RSSFIT_ROOT_PATH')) {
40
    exit();
41
}
42
43
/**
44
 * Class Smartsection
45
 * @package XoopsModules\Rssfit\Plugins
46
 */
47
class Smartsection
48
{
49
    public $dirname = 'smartsection';
50
    public $modname;
51
    public $grab;
52
53
    /**
54
     * @return \XoopsModule
55
     */
56
    public function loadModule():?\XoopsModule
57
    {
58
        $mod = $GLOBALS['module_handler']->getByDirname($this->dirname);
59
        if (!$mod || !$mod->getVar('isactive')) {
60
            return null;
61
        }
62
        $this->modname = $mod->getVar('name');
63
64
        return $mod;
65
    }
66
67
    /**
68
     * @return array
69
     */
70
    public function grabEntries(\XoopsMySQLDatabase $xoopsDB):?array
0 ignored issues
show
Unused Code introduced by
The parameter $xoopsDB 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

70
    public function grabEntries(/** @scrutinizer ignore-unused */ \XoopsMySQLDatabase $xoopsDB):?array

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...
71
    {
72
        $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
73
        $ret  = null;
74
        require_once XOOPS_ROOT_PATH . '/modules/smartsection/include/common.php';
75
        $helper      = SmartsectionHelper::getInstance();
76
        $itemHandler = $helper->getHandler('Item');
77
        $items       = $itemHandler->getAllPublished($this->grab, 0);
78
        if (false !== $items && \count($items) > 0) {
79
            $ret = [];
80
            for ($i = 0, $iMax = \count($items); $i < $iMax; ++$i) {
81
                $ret[$i]['link']        = $ret[$i]['guid'] = $items[$i]->getItemUrl();
82
                $ret[$i]['title']       = $items[$i]->getVar('title', 'n');
83
                $ret[$i]['timestamp']   = $items[$i]->getVar('datesub');
84
                $ret[$i]['description'] = $items[$i]->getVar('summary');
85
                $ret[$i]['category']    = $this->modname;
86
                $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
87
            }
88
        }
89
90
        return $ret;
91
    }
92
}
93