Completed
Push — master ( 658b35...b781ca )
by Richard
28s queued 23s
created

Helper   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 94
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 16
dl 0
loc 94
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A getCategoryHandler() 0 3 1
A getPermissionHandler() 0 3 1
A getHandler() 0 9 1
A init() 0 5 1
A getGrouppermHandler() 0 3 1
A getInstance() 0 3 1
A getRatingHandler() 0 3 1
A getMimetypeHandler() 0 3 1
A getFileHandler() 0 3 1
A getItemHandler() 0 3 1
1
<?php
2
3
namespace XoopsModules\Publisher;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 *  Publisher class
17
 *
18
 * @copyright       The XUUPS Project http://sourceforge.net/projects/xuups/
19
 * @license         GNU GPL V2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
20
 * @package         Class
21
 * @subpackage      Utils
22
 * @since           1.0
23
 * @author          trabis <[email protected]>
24
 * @version         $Id$
25
 */
26
use Xoops\Module\Helper\HelperAbstract;
27
use XoopsDatabaseFactory;
28
use XoopsModules\Publisher;
29
30
/**
31
 * Class Helper
32
 * @package XoopsModules\Publisher
33
 */
34
class Helper extends HelperAbstract
35
{
36
    /**
37
     * Init the module
38
     *
39
     * @return null|void
40
     */
41
    public function init()
42
    {
43
        $this->setDirname('publisher');
44
        //$this->setDebug(true);
45
        $this->loadLanguage('modinfo');
46
    }
47
48
    /**
49
     * @return Helper
50
     */
51
    public static function getInstance()
52
    {
53
        return parent::getInstance();
54
    }
55
56
    /**
57
     * @return \XoopsModules\Publisher\ItemHandler
58
     */
59
    public function getItemHandler(): ItemHandler
60
    {
61
        return $this->getHandler('Item');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getHandler('Item') returns the type XoopsObjectHandler|Xoops...leObjectHandler|boolean which is incompatible with the type-hinted return XoopsModules\Publisher\ItemHandler.
Loading history...
62
    }
63
64
    /**
65
     * @return \XoopsModules\Publisher\CategoryHandler
66
     */
67
    public function getCategoryHandler(): CategoryHandler
68
    {
69
        return $this->getHandler('Category');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getHandler('Category') returns the type XoopsObjectHandler|Xoops...leObjectHandler|boolean which is incompatible with the type-hinted return XoopsModules\Publisher\CategoryHandler.
Loading history...
70
    }
71
72
    /**
73
     * @return \XoopsModules\Publisher\PermissionHandler
74
     */
75
    public function getPermissionHandler(): PermissionHandler
76
    {
77
        return $this->getHandler('Permission');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getHandler('Permission') returns the type XoopsObjectHandler|Xoops...leObjectHandler|boolean which is incompatible with the type-hinted return XoopsModules\Publisher\PermissionHandler.
Loading history...
78
    }
79
80
    /**
81
     * @return \XoopsModules\Publisher\FileHandler
82
     */
83
    public function getFileHandler(): FileHandler
84
    {
85
        return $this->getHandler('File');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getHandler('File') returns the type XoopsObjectHandler|Xoops...leObjectHandler|boolean which is incompatible with the type-hinted return XoopsModules\Publisher\FileHandler.
Loading history...
86
    }
87
88
    /**
89
     * @return \XoopsModules\Publisher\MimetypeHandler
90
     */
91
    public function getMimetypeHandler(): MimetypeHandler
92
    {
93
        return $this->getHandler('Mimetype');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getHandler('Mimetype') returns the type XoopsObjectHandler|Xoops...leObjectHandler|boolean which is incompatible with the type-hinted return XoopsModules\Publisher\MimetypeHandler.
Loading history...
94
    }
95
96
    /**
97
     * @return \XoopsModules\Publisher\RatingHandler
98
     */
99
    public function getRatingHandler(): RatingHandler
100
    {
101
        return $this->getHandler('Rating');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getHandler('Rating') returns the type XoopsObjectHandler|Xoops...leObjectHandler|boolean which is incompatible with the type-hinted return XoopsModules\Publisher\RatingHandler.
Loading history...
102
    }
103
104
    /**
105
     * @return \XoopsModules\Publisher\GroupPermHandler
106
     */
107
    public function getGrouppermHandler(): GroupPermHandler
108
    {
109
        return $this->getHandler('Groupperm');
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->getHandler('Groupperm') returns the type XoopsObjectHandler|Xoops...leObjectHandler|boolean which is incompatible with the type-hinted return XoopsModules\Publisher\GroupPermHandler.
Loading history...
110
    }
111
112
    /**
113
     * Get an Object Handler
114
     *
115
     * @param string $name name of handler to load
116
     *
117
     * @return bool|\XoopsObjectHandler|\XoopsPersistableObjectHandler
118
     */
119
    public function getHandler($name)
120
    {
121
        $ret = false;
0 ignored issues
show
Unused Code introduced by
The assignment to $ret is dead and can be removed.
Loading history...
122
        //        /** @var Connection $db */
123
        $db = XoopsDatabaseFactory::getConnection();
124
        $class = '\\XoopsModules\\' . \ucfirst(mb_strtolower(\basename(\dirname(__DIR__)))) . '\\' . $name . 'Handler';
125
        $ret = new $class($db);
126
127
        return $ret;
128
    }
129
}
130