Headline   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
dl 0
loc 33
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 1
A cacheExpired() 0 7 2
1
<?php declare(strict_types=1);
2
3
namespace XoopsModules\Xoopsheadline;
4
5
/*
6
 * You may not change or alter any portion of this comment or credits
7
 * of supporting developers from this source code or any supporting source code
8
 * which is considered copyrighted (c) material of the original comment or credit authors.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
use XoopsObject;
16
17
/**
18
 * @copyright    XOOPS Project (https://xoops.org)
19
 * @license      GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
20
 * @author       XOOPS Development Team, Kazumi Ono (AKA onokazu)
21
 */
22
23
/**
24
 * Class Headline
25
 */
26
class Headline extends XoopsObject
27
{
28
    /**
29
     * Headline constructor.
30
     */
31
    public function __construct()
32
    {
33
        parent::__construct();
34
        $this->initVar('headline_id', \XOBJ_DTYPE_INT, null, false);
35
        $this->initVar('headline_name', \XOBJ_DTYPE_TXTBOX, null, true, 255);
36
        $this->initVar('headline_url', \XOBJ_DTYPE_TXTBOX, null, true, 255);
37
        $this->initVar('headline_rssurl', \XOBJ_DTYPE_TXTBOX, null, true, 255);
38
        $this->initVar('headline_cachetime', \XOBJ_DTYPE_INT, 600, false);
39
        $this->initVar('headline_asblock', \XOBJ_DTYPE_INT, 0, false);
40
        $this->initVar('headline_display', \XOBJ_DTYPE_INT, 0, false);
41
        $this->initVar('headline_encoding', \XOBJ_DTYPE_OTHER, null, false);
42
        $this->initVar('headline_weight', \XOBJ_DTYPE_INT, 0, false);
43
        $this->initVar('headline_mainimg', \XOBJ_DTYPE_INT, 1, false);
44
        $this->initVar('headline_mainfull', \XOBJ_DTYPE_INT, 1, false);
45
        $this->initVar('headline_mainmax', \XOBJ_DTYPE_INT, 10, false);
46
        $this->initVar('headline_blockimg', \XOBJ_DTYPE_INT, 0, false);
47
        $this->initVar('headline_blockmax', \XOBJ_DTYPE_INT, 10, false);
48
        $this->initVar('headline_xml', \XOBJ_DTYPE_SOURCE, null, false);
49
        $this->initVar('headline_updated', \XOBJ_DTYPE_INT, 0, false);
50
    }
51
52
    public function cacheExpired(): bool
53
    {
54
        if (\time() - $this->getVar('headline_updated') > $this->getVar('headline_cachetime')) {
55
            return true;
56
        }
57
58
        return false;
59
    }
60
}
61