Ams::grabEntries()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 19
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 13
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 19
rs 9.8333
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: brash <http://www.it-hq.org>
28
* Requirements (Tested with):
29
*  Module: AMS <http://www.it-hq.org>
30
*  Version: 2.41
31
*  RSSFit verision: 1.2 / 1.5
32
*  XOOPS version: 2.0.13.2 / 2.2.3
33
*/
34
35
use XoopsModules\Ams\Story;
0 ignored issues
show
Bug introduced by
The type XoopsModules\Ams\Story 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...
36
use XoopsModules\Rssfit\{
37
    AbstractPlugin
38
};
39
40
use XoopsModules\Ams\Helper as PluginHelper;
41
42
if (!\defined('RSSFIT_ROOT_PATH')) {
43
    exit();
44
}
45
46
/**
47
 * Class Ams
48
 * @package XoopsModules\Rssfit\Plugins
49
 */
50
final class Ams extends AbstractPlugin
51
{
52
    public function __construct() {
53
        if (\class_exists(PluginHelper::class)) {
54
            $this->helper = PluginHelper::getInstance();
55
            $this->dirname = $this->helper->dirname();
56
        }
57
    }
58
59
    public function grabEntries(\XoopsMySQLDatabase $xoopsDB): ?array
60
    {
61
        $ret = null;
62
        //        @require_once XOOPS_ROOT_PATH . '/modules/AMS/class/class.newsstory.php';
63
        $myts = \MyTextSanitizer::getInstance();
64
        $ams  = Story::getAllPublished($this->grab, 0);
65
        if (\count($ams) > 0) {
66
            $ret = [];
67
            for ($i = 0, $iMax = \count($ams); $i < $iMax; ++$i) {
68
                $ret[$i]['title']       = $myts->undoHtmlSpecialChars($ams[$i]->title());
69
                $ret[$i]['link']        = $ret[$i]['guid'] = XOOPS_URL . "/modules/$this->dirname/article.php?storyid=" . $ams[$i]->storyid();
70
                $ret[$i]['timestamp']   = $ams[$i]->published();
71
                $ret[$i]['description'] = $ams[$i]->hometext();
72
                $ret[$i]['category']    = $this->modname;
73
                $ret[$i]['domain']      = XOOPS_URL . '/modules/' . $this->dirname . '/';
74
            }
75
        }
76
77
        return $ret;
78
    }
79
}
80