Buyersguide   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 29
c 0
b 0
f 0
dl 0
loc 50
rs 10
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadModule() 0 9 3
A grabEntries() 0 27 5
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: Hervé Thouzard of Instant Zero (http://www.instant-zero.com)
28
 * Requirements (Tested with):
29
 *  Module: Buyersguide
30
 *  Version: 1.33
31
 * Flux RSS : Derniers produits
32
 *  RSSFit verision: 1.22
33
 *  XOOPS version: 2.0.18.1
34
 */
35
if (!\defined('RSSFIT_ROOT_PATH')) {
36
    exit();
37
}
38
39
/**
40
 * Class Buyersguide
41
 */
42
class Buyersguide
43
{
44
    public $dirname = 'buyersguide';
45
    public $modname;
46
    public $grab;
47
48
    /**
49
     * @return \XoopsModule
50
     */
51
    public function loadModule():?\XoopsModule
52
    {
53
        $mod = $GLOBALS['module_handler']->getByDirname($this->dirname);
54
        if (!$mod || !$mod->getVar('isactive')) {
55
            return null;
56
        }
57
        $this->modname = $mod->getVar('name');
58
59
        return $mod;
60
    }
61
62
    /**
63
     * @return array
64
     */
65
    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

65
    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...
66
    {
67
        $myts = \MyTextSanitizer::getInstance();
0 ignored issues
show
Unused Code introduced by
The assignment to $myts is dead and can be removed.
Loading history...
68
        $ret  = null;
69
        require_once XOOPS_ROOT_PATH . '/modules/buyersguide/include/common.php';
70
        $items = $hBgProduct->getRecentProducts(0, 0, $this->grab);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $hBgProduct seems to be never defined.
Loading history...
71
        $i = 0;
72
73
        if (false !== $items && \count($items) > 0) {
74
            $ret = [];
75
            foreach ($items as $item) {
76
                $ret[$i]['link'] = $ret[$i]['guid'] = $item->getLink();
77
                $ret[$i]['title'] = $item->getVar('prod_title', 'n');
78
                $ret[$i]['timestamp'] = $item->getVar('prod_submited_date');
79
                if ('' != \xoops_trim($item->getVar('prod_summary'))) {
80
                    $description = $item->getVar('prod_summary');
81
                } else {
82
                    $description = $item->getVar('prod_description');
83
                }
84
                $ret[$i]['description'] = $description;
85
                $ret[$i]['category'] = $this->modname;
86
                $ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/';
87
                $i++;
88
            }
89
        }
90
91
        return $ret;
92
    }
93
}
94