Completed
Pull Request — master (#9)
by Michael
01:20
created

XoopspartnersPartnersHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 10
c 0
b 0
f 0
wmc 1
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 34 and the first side effect is on line 26.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/*
3
 * You may not change or alter any portion of this comment or credits
4
 * of supporting developers from this source code or any supporting source code
5
 * which is considered copyrighted (c) material of the original comment or credit authors.
6
 * This program is distributed in the hope that it will be useful,
7
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
 *
10
 *------------------------------------
11
 * Author: Raul Recio (AKA UNFOR)
12
 * Project: The XOOPS Project
13
 *------------------------------------
14
 */
15
/**
16
 * XoopsPartners - a partner affiliation links module
17
 *
18
 * @package      module\xoopspartners\class
19
 * @author       Raul Recio (aka UNFOR)
20
 * @author       XOOPS Module Development Team
21
 * @copyright    {@link https://xoops.org 2001-2016 XOOPS Project}
22
 * @license      {@link http://www.gnu.org/licenses/gpl-2.0.html GNU Public License}
23
 * @link         https://xoops.org XOOPS
24
 */
25
26
defined('XOOPS_ROOT_PATH') || exit('Restricted access');
27
28
/**
29
 * Class XoopspartnersPartners
30
 *
31
 * {@inheritDoc}
32
 * @see XoopsObject
33
 */
34
class XoopspartnersPartners extends XoopsObject
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
35
{
36
    protected $db;
37
38
    /**
39
     * constructor
40
     *
41
     * @todo change 'url' to XOBJ_DTYPE_URL
42
     * @param null $id
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);
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');
73
    }
74
}
75
76
/**
77
 *
78
 * {@inheritDoc}
79
 * @see XoopsPersistableObjectHandler
80
 * @copyright copyright &copy; 2000 XOOPS.org
81
 *
82
 */
83
class XoopspartnersPartnersHandler extends XoopsPersistableObjectHandler
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
84
{
85
    /**
86
     * XoopspartnersPartnersHandler constructor
87
     *
88
     * @param XoopsDatabase $db
89
     */
90
    public function __construct(XoopsDatabase $db)
91
    {
92
        parent::__construct($db, 'partners', 'XoopspartnersPartners', 'id', 'title');
93
    }
94
}
95