Passed
Pull Request — master (#10)
by Michael
03:25
created

Partners   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 17
dl 0
loc 39
rs 10
c 1
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 17 3
A __toString() 0 3 1
1
<?php
2
3
namespace XoopsModules\Xoopspartners;
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
 * This program is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
 *
13
 *------------------------------------
14
 * Author: Raul Recio (AKA UNFOR)
15
 * Project: The XOOPS Project
16
 *------------------------------------
17
 */
18
/**
19
 * XoopsPartners - a partner affiliation links module
20
 *
21
 * @package      module\Xoopspartners\class
22
 * @author       Raul Recio (aka UNFOR)
23
 * @author       XOOPS Module Development Team
24
 * @copyright    {@link https://xoops.org 2001-2016 XOOPS Project}
25
 * @license      {@link https://www.gnu.org/licenses/gpl-2.0.html GNU Public License}
26
 * @link         https://xoops.org XOOPS
27
 */
28
/**
29
 * Class Partners
30
 *
31
 * {@inheritDoc}
32
 * @see \XoopsObject
33
 */
34
class Partners extends \XoopsObject
35
{
36
    protected $db;
37
38
    /**
39
     * constructor
40
     *
41
     * @param null $id
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $id is correct as it would always require null to be passed?
Loading history...
42
     * @todo change 'url' to XOBJ_DTYPE_URL
43
     */
44
    public function __construct($id = null)
45
    {
46
        $this->db = \XoopsDatabaseFactory::getDatabaseConnection();
47
48
        $this->initVar('id', \XOBJ_DTYPE_INT, null, false);
49
        $this->initVar('weight', \XOBJ_DTYPE_INT, null, false, 10);
50
        $this->initVar('hits', \XOBJ_DTYPE_INT, null, true, 10);
51
        $this->initVar('url', \XOBJ_DTYPE_TXTBOX, null, true);
52
        $this->initVar('image', \XOBJ_DTYPE_TXTBOX, null, true);
53
        $this->initVar('title', \XOBJ_DTYPE_TXTBOX, null, false);
54
        $this->initVar('description', \XOBJ_DTYPE_TXTBOX, null, true);
55
        $this->initVar('status', \XOBJ_DTYPE_INT, null, false, 0);
56
        if (!empty($id)) {
57
            if (\is_array($id)) {
58
                $this->assignVars($id);
59
            } else {
60
                $this->load((int)$id);
0 ignored issues
show
Bug introduced by
The method load() does not exist on XoopsModules\Xoopspartners\Partners. ( Ignorable by Annotation )

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

60
                $this->/** @scrutinizer ignore-call */ 
61
                       load((int)$id);

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...
61
            }
62
        }
63
    }
64
65
    /**
66
     * Returns category title
67
     *
68
     * @return string
69
     */
70
    public function __toString()
71
    {
72
        return $this->getVar('title', 's');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getVar('title', 's') also could return the type array|boolean which is incompatible with the documented return type string.
Loading history...
73
    }
74
}
75