mgo_getClass()   B
last analyzed

Complexity

Conditions 7
Paths 16

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 8
nc 16
nop 2
dl 0
loc 16
rs 8.8333
c 1
b 0
f 0
1
<?php
2
### =============================================================
3
### Mastop InfoDigital - Paixão por Internet
4
### =============================================================
5
### Funções Padrão para o Módulo
6
### =============================================================
7
### Developer: Fernando Santos (topet05), [email protected]
8
### Copyright: Mastop InfoDigital © 2003-2007
9
### -------------------------------------------------------------
10
### www.mastop.com.br
11
### =============================================================
12
###
13
### =============================================================
14
15
/**
16
 * @param      $classe
17
 * @param null $id
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $id is correct as it would always require null to be passed?
Loading history...
18
 *
19
 * @return bool
20
 */
21
function mgo_getClass($classe, $id = null)
22
{
23
    static $classes;
24
    if (!isset($classes[$classe])) {
25
        //        if (file_exists($arquivo = XOOPS_ROOT_PATH . '/modules/' . MGO_MOD_DIR . '/class/' . $classe . '.class.php')) {
26
        //            require_once $arquivo;
27
        //        }
28
        if (class_exists($classe)) {
29
            $classtemp        = '\XoopsModules\Mastopgo2\\' . $classe;
30
            $classes[$classe] = new $classtemp($id);
31
        }
32
    } elseif (is_object($classes[$classe]) && !empty($id)) {
33
        $classes[$classe]->__construct($id);
34
    }
35
36
    return isset($classes[$classe]) && is_object($classes[$classe]) ? $classes[$classe] : false;
37
}
38
39
/**
40
 * @param $dirname
41
 *
42
 * @return bool
43
 */
44
function mgo_getModuleConfig($dirname)
45
{
46
    static $modulesConfig;
47
    if (!isset($modulesConfig[$dirname])) {
48
        /** @var \XoopsModuleHandler $moduleHandler */
49
        $moduleHandler           = xoops_getHandler('module');
50
        $module                  = $moduleHandler->getByDirname($dirname);
51
        $configHandler           = xoops_getHandler('config');
52
        $modulesConfig[$dirname] = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
0 ignored issues
show
Bug introduced by
The method getConfigsByCat() does not exist on XoopsObjectHandler. It seems like you code against a sub-type of XoopsObjectHandler such as XoopsPersistableObjectHandler. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

52
        /** @scrutinizer ignore-call */ 
53
        $modulesConfig[$dirname] = $configHandler->getConfigsByCat(0, $module->getVar('mid'));
Loading history...
53
    }
54
55
    return isset($modulesConfig[$dirname]) && is_array($modulesConfig[$dirname]) ? $modulesConfig[$dirname] : false;
56
}
57