Passed
Push — master ( b847d6...d6d54c )
by Michael
09:34 queued 05:00
created

class/Helper.php (2 issues)

1
<?php namespace XoopsModules\Pedigree;
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
    public function __construct($debug = false)
35
    {
36
        if (null === $dirname) {
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $dirname seems to be never defined.
Loading history...
37
            $dirname = basename(dirname(__DIR__));
38
            $this->dirname = $dirname;
39
        }
40
        parent::__construct($moduleDirName);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $moduleDirName seems to be never defined.
Loading history...
41
    }
42
43
    /**
44
     * @param bool $debug
45
     *
46
     * @return \XoopsModules\Pedigree\Helper
47
     */
48
    public static function getInstance($debug = false)
49
    {
50
        static $instance;
51
        if (null === $instance) {
52
            $instance = new static($debug);
53
        }
54
55
        return $instance;
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getDirname()
62
    {
63
        return $this->dirname;
64
    }
65
66
    /**
67
     * Get an Object Handler
68
     *
69
     * @param string $name name of handler to load
70
     *
71
     * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler
72
     */
73
    public function getHandler($name)
74
    {
75
        $ret   = false;
76
        $db    = \XoopsDatabaseFactory::getDatabaseConnection();
77
        $class = __NAMESPACE__ . '\\' . ucfirst($name) . 'Handler';
78
        return new $class($db);
79
    }
80
}
81