Completed
Push — master ( 10bab4...a0a78b )
by Michael
02:06
created

Helper   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 54
rs 10
c 0
b 0
f 0
wmc 5
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getInstance() 0 9 2
A getDirname() 0 4 1
A getHandler() 0 8 1
1
<?php namespace XoopsModules\Planet;
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
defined('XOOPS_ROOT_PATH') || die('Restricted access');
22
23
/**
24
 * Class Helper
25
 */
26
class Helper extends \Xmf\Module\Helper
27
{
28
    public $debug;
29
30
    /**
31
     *
32
     * @param bool $debug
33
     */
34
    protected function __construct($debug = false)
35
    {
36
        $this->debug   = $debug;
37
        $moduleDirName = basename(dirname(__DIR__));
38
        parent::__construct($moduleDirName);
39
    }
40
41
    /**
42
     * @param bool $debug
43
     *
44
     * @return \Xmf\Module\Helper
45
     */
46
    public static function getInstance($debug = false)
47
    {
48
        static $instance;
49
        if (null === $instance) {
50
            $instance = new static($debug);
51
        }
52
53
        return $instance;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getDirname()
60
    {
61
        return $this->dirname;
62
    }
63
64
    /**
65
     * Get an Object Handler
66
     *
67
     * @param string $name name of handler to load
68
     *
69
     * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler
70
     */
71
    public function getHandler($name)
72
    {
73
        $ret   = false;
0 ignored issues
show
Unused Code introduced by
$ret is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
74
        $db    = \XoopsDatabaseFactory::getDatabaseConnection();
75
        $class = '\\XoopsModules\\' . ucfirst(strtolower(basename(dirname(__DIR__)))) . '\\' . $name . 'Handler';
76
        $ret   = new $class($db);
77
        return $ret;
78
    }
79
}
80