Passed
Push — master ( cf57bc...9eba79 )
by Michael
01:41
created

oninstall.php ➔ xoops_module_pre_install_gbook()   B

Complexity

Conditions 5
Paths 8

Size

Total Lines 25
Code Lines 13

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 13
nc 8
nop 1
dl 0
loc 25
rs 8.439
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B xoops_module_pre_install_gbook() 0 24 5
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
/**
13
 * @copyright    XOOPS Project https://xoops.org/
14
 * @license      GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @author     XOOPS Development Team
16
 */
17
18
use XoopsModules\Gbook;
19
20
/**
21
 *
22
 * Prepares system prior to attempting to install module
23
 * @param XoopsModule $module {@link XoopsModule}
24
 *
25
 * @return bool true if ready to install, false if not
26
 */
27
function xoops_module_pre_install_gbook(\XoopsModule $module)
28
{
29
    $moduleDirName = basename(dirname(__DIR__));
30
    /** @var Gbook\Utility $utilityClass */
31
    $utilityClass = ucfirst($moduleDirName) . 'Utility';
32
    if (!class_exists($utilityClass)) {
0 ignored issues
show
Bug introduced by
$utilityClass of type XoopsModules\Gbook\Utility is incompatible with the type string expected by parameter $class_name of class_exists(). ( Ignorable by Annotation )

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

32
    if (!class_exists(/** @scrutinizer ignore-type */ $utilityClass)) {
Loading history...
33
        xoops_load('utility', $moduleDirName);
0 ignored issues
show
Bug introduced by
The function xoops_load was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

33
        /** @scrutinizer ignore-call */ 
34
        xoops_load('utility', $moduleDirName);
Loading history...
34
    }
35
    //check for minimum XOOPS version
36
    if (!$utilityClass::checkVerXoops($module)) {
37
        return false;
38
    }
39
40
    // check for minimum PHP version
41
    if (!$utilityClass::checkVerPhp($module)) {
42
        return false;
43
    }
44
45
    $mod_tables =& $module->getInfo('tables');
46
    foreach ($mod_tables as $table) {
47
        $GLOBALS['xoopsDB']->queryF('DROP TABLE IF EXISTS ' . $GLOBALS['xoopsDB']->prefix($table) . ';');
48
    }
49
50
    return true;
51
}
52
53
/**
54
 *
55
 * Performs tasks required during installation of the module
56
 * @param XoopsModule $module {@link XoopsModule}
57
 *
58
 * @return bool true if installation successful, false if not
59
 */
60
function xoops_module_install_gbook(\XoopsModule $module)
0 ignored issues
show
Unused Code introduced by
The parameter $module is not used and could be removed. ( Ignorable by Annotation )

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

60
function xoops_module_install_gbook(/** @scrutinizer ignore-unused */ \XoopsModule $module)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
61
{
62
    return true;
63
}
64