TagHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getLanguages() 0 11 2
1
<?php namespace XoopsModules\Smartobject;
2
3
/*
4
 * You may not change or alter any portion of this comment or credits
5
 * of supporting developers from this source code or any supporting source code
6
 * which is considered copyrighted (c) material of the original comment or credit authors.
7
 *
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 */
12
13
/**
14
 * @copyright    XOOPS Project https://xoops.org/
15
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
16
 * @package
17
 * @since
18
 * @author     XOOPS Development Team
19
 */
20
21
use XoopsLists;
22
use XoopsModules\Smartobject;
23
24
// defined('XOOPS_ROOT_PATH') || die('Restricted access');
25
//require_once XOOPS_ROOT_PATH . '/modules/smartobject/class/smartmlobject.php';
26
27
/**
28
 * Class SmartobjectTagHandler
29
 */
30
class TagHandler extends Smartobject\PersistableMlObjectHandler
31
{
32
    /**
33
     * SmartobjectTagHandler constructor.
34
     * @param \XoopsDatabase $db
35
     */
36
    public function __construct(\XoopsDatabase $db)
37
    {
38
        parent::__construct($db, 'tag', 'tagid', 'name', 'description', 'smartobject');
39
    }
40
41
    /**
42
     * @return mixed
43
     */
44
    public function getLanguages()
45
    {
46
        require_once XOOPS_ROOT_PATH . '/class/xoopslists.php';
47
        $aLanguages     = XoopsLists::getLangList();
48
        $ret['default'] = _CO_SOBJECT_ALL;
0 ignored issues
show
Coding Style Comprehensibility introduced by
$ret was never initialized. Although not strictly required by PHP, it is generally a good practice to add $ret = array(); before regardless.

Adding an explicit array definition is generally preferable to implicit array definition as it guarantees a stable state of the code.

Let’s take a look at an example:

foreach ($collection as $item) {
    $myArray['foo'] = $item->getFoo();

    if ($item->hasBar()) {
        $myArray['bar'] = $item->getBar();
    }

    // do something with $myArray
}

As you can see in this example, the array $myArray is initialized the first time when the foreach loop is entered. You can also see that the value of the bar key is only written conditionally; thus, its value might result from a previous iteration.

This might or might not be intended. To make your intention clear, your code more readible and to avoid accidental bugs, we recommend to add an explicit initialization $myArray = array() either outside or inside the foreach loop.

Loading history...
49
        foreach ($aLanguages as $lang) {
50
            $ret[$lang] = $lang;
51
        }
52
53
        return $ret;
54
    }
55
}
56