Test Failed
Push — master ( 398493...d4ef72 )
by Michael
11:04
created

Helper   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 30
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getHelper() 0 21 4
1
<?php
2
/*
3
 You may not change or alter any portion of this comment or credits
4
 of supporting developers from this source code or any supporting source code
5
 which is considered copyrighted (c) material of the original comment or credit authors.
6
7
 This program is distributed in the hope that it will be useful,
8
 but WITHOUT ANY WARRANTY; without even the implied warranty of
9
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11
12
namespace Xmf\Module;
13
14
use Xmf\Module\Helper\GenericHelper;
15
16
/**
17
 * Helper gets an instance of module helper for the specified module.
18
 * The helper is defined by the Xoops 2.6 Xoops\Module\Helper\HelperAbstract
19
 * and in pre 2.6 systems we mimic that definition with using an
20
 * instance of Xmf\Module\GenericHelper.
21
 *
22
 * @category  Xmf\Module\Helper
23
 * @package   Xmf
24
 * @author    trabis <[email protected]>
25
 * @author    Richard Griffith <[email protected]>
26
 * @copyright 2011-2018 XOOPS Project (https://xoops.org)
27
 * @license   GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
28
 * @link      https://xoops.org
29
 */
30
class Helper extends GenericHelper
31
{
32
    /**
33
     * Get an instance of a module helper for the module identified by $dirname
34
     *
35
     * @param string $dirname module directory
36
     *
37
     * @return \Xmf\Module\Helper|\Xoops\Module\Helper|false a Helper object of false on error
38
     */
39
    public static function getHelper($dirname = 'system')
40
    {
41
        static $instance = array();
42
43
        //$dirname = strtolower($dirname);
44
45
        if (!isset($instance[$dirname])) {
46
            $instance[$dirname] = false;
47
48
            // if this is a 2.6 system turn everything over to the core
49
            if (class_exists('Xoops', false)) {
50
                $instance[$dirname] = \Xoops\Module\Helper::getHelper($dirname);
0 ignored issues
show
Bug introduced by
The type Xoops\Module\Helper was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
51
            } else {
52
                // otherwise get a GenericHelper instance for dirname
53
                if (xoops_isActiveModule($dirname)) {
54
                    $instance[$dirname] = new static($dirname);
55
                }
56
            }
57
        }
58
59
        return $instance[$dirname];
60
    }
61
}
62