Helper   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 51
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDirname() 0 3 1
A getInstance() 0 7 2
A __construct() 0 5 1
A getHandler() 0 7 1
1
<?php namespace XoopsModules\Cardealer;
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
 * Module: cardealer
14
 *
15
 * @category        Module
16
 * @package         cardealer
17
 * @author          XOOPS Development Team <[email protected]> - <https://xoops.org>
18
 * @copyright       {@link https://xoops.org/ XOOPS Project}
19
 * @license         GPL 2.0 or later
20
 * @link            https://xoops.org/
21
 * @since           1.0.0
22
 */
23
24
/**
25
 * Class Helper
26
 */
27
class Helper extends \Xmf\Module\Helper
28
{
29
    public $debug;
30
31
    /**
32
     * Constructor
33
     *
34
     * @param bool $debug
35
     */
36
    public function __construct($debug = false)
37
    {
38
        $this->debug   = $debug;
39
        $moduleDirName = basename(dirname(__DIR__));
40
        parent::__construct($moduleDirName);
41
    }
42
43
    /**
44
     * @param bool $debug
45
     * @return \XoopsModules\Cardealer\Helper
46
     */
47
    public static function getInstance($debug = false)
48
    {
49
        static $instance;
50
        if (null === $instance) {
51
            $instance = new static($debug);
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
The assignment to $ret is dead and can be removed.
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
}
81