Completed
Branch master (9dda00)
by Michael
04:54 queued 02:33
created

functions.recon.php ➔ newbbSynchronization()   C

Complexity

Conditions 7
Paths 36

Size

Total Lines 35
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 26
nc 36
nop 1
dl 0
loc 35
rs 6.7272
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 15 and the first side effect is on line 14.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
/**
3
 * NewBB 5.0x,  the forum module for XOOPS project
4
 *
5
 * @copyright      XOOPS Project (http://xoops.org)
6
 * @license        GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
7
 * @author         Taiwen Jiang (phppp or D.J.) <[email protected]>
8
 * @since          4.00
9
 * @package        module::newbb
10
 */
11
12
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
13
14
defined('NEWBB_FUNCTIONS_INI') || include __DIR__ . '/functions.ini.php';
15
define('NEWBB_FUNCTIONS_RECON_LOADED', true);
16
17
if (!defined('NEWBB_FUNCTIONS_RECON')) {
18
    define('NEWBB_FUNCTIONS_RECON', 1);
19
20
    /**
21
     * @param  null $type
22
     * @return bool
23
     */
24
    function newbbSynchronization($type = null)
0 ignored issues
show
Unused Code introduced by
The parameter $type is not used and could be removed.

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

Loading history...
25
    {
26
        $allTypes = [
27
            'category',
28
            'forum',
29
            'topic',
30
            'post',
31
            'report',
32
            'rate',
33
            'moderate',
34
            'readtopic',
35
            'readforum',
36
            'stats'
37
        ];
38
        $type     = [];
39
        $type     = empty($type) ? $allTypes : (is_array($type) ? $type : [$type]);
40
        foreach ($type as $item) {
41
            $handler = xoops_getModuleHandler($item, 'newbb');
42
            if ($item !== 'stats') {
43
                $handler->synchronization();
44
            } else {
45
                $handler->reset();
46
            }
47
48
            if (method_exists($handler, 'cleanExpires')) {
49
                $handler->cleanExpires();
50
            }
51
            if (method_exists($handler, 'clearGarbage')) {
52
                $handler->clearGarbage();
53
            }
54
            unset($handler);
55
        }
56
57
        return true;
58
    }
59
}
60