XoositemapPlugin   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 25
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A Xoositemap_xml() 0 18 3
A Xoositemap() 0 19 2
1
<?php
2
3
namespace XoopsModules\Xooghost\Plugin;
4
5
/**
6
 * Xooghost module
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       XOOPS Project (https://xoops.org)
16
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
17
 * @package         Xooghost
18
 * @since           2.6.0
19
 * @author          Laurent JEN (Aka DuGris)
20
 */
21
22
/**
23
 * Class XooghostXoositemapPlugin
24
 */
25
class XoositemapPlugin extends \Xoops\Module\Plugin\PluginAbstract implements \XoositemapPluginInterface
0 ignored issues
show
Bug introduced by
The type XoositemapPluginInterface 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...
26
{
27
    /**
28
     * @param $subcategories
29
     *
30
     * @return array
31
     */
32
    public function Xoositemap($subcategories)
33
    {
34
        $helper = \XoopsModules\Xooghost\Helper::getInstance();
35
        $pageHandler = $helper->getHandler('Page');
36
37
        $pages = $pageHandler->getPublished('published', 'desc');
0 ignored issues
show
Bug introduced by
The method getPublished() does not exist on XoopsObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
        /** @scrutinizer ignore-call */ 
38
        $pages = $pageHandler->getPublished('published', 'desc');

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
39
        $sitemap = [];
40
        foreach ($pages as $k => $page) {
41
            $sitemap[$k]['id'] = $k;
42
            $sitemap[$k]['title'] = $page['xooghost_title'];
43
            $sitemap[$k]['url'] = $page['xooghost_link'];
44
            $sitemap[$k]['uid'] = $page['xooghost_uid'];
45
            $sitemap[$k]['uname'] = $page['xooghost_uid_name'];
46
            $sitemap[$k]['image'] = $page['xooghost_image_link'];
47
            $sitemap[$k]['time'] = $page['xooghost_time'];
48
        }
49
50
        return $sitemap;
51
    }
52
53
    /**
54
     * @param $subcategories
55
     *
56
     * @return array
57
     */
58
    public function Xoositemap_xml($subcategories)
59
    {
60
        $helper = \XoopsModules\Xooghost\Helper::getInstance();
61
        $pageHandler = $helper->getHandler('Page');
62
63
        $sitemap = [];
64
        $time = 0;
65
66
        $pages = $pageHandler->getPublished('published', 'desc');
67
        foreach ($pages as $k => $page) {
68
            $sitemap[$k]['url'] = $page['xooghost_link'];
69
            $sitemap[$k]['time'] = $page['xooghost_time'];
70
            if ($time < $page['xooghost_time']) {
71
                $time = $page['xooghost_time'];
72
            }
73
        }
74
75
        return ['dirname' => \XoopsModules\Xooghost\Helper::getInstance()->getModule()->getVar('dirname'), 'time' => $time, 'items' => $sitemap];
76
    }
77
}
78