newbbSynchronization()   B
last analyzed

Complexity

Conditions 7
Paths 36

Size

Total Lines 34
Code Lines 25

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 25
nc 36
nop 1
dl 0
loc 34
rs 8.5866
c 0
b 0
f 0
1
<?php
2
/**
3
 * NewBB 5.0x,  the forum module for XOOPS project
4
 *
5
 * @copyright      XOOPS Project (https://xoops.org)
6
 * @license        GNU GPL 2 or later (https://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
use XoopsModules\Newbb;
13
14
15
16
defined('NEWBB_FUNCTIONS_INI') || require __DIR__ . '/functions.ini.php';
17
define('NEWBB_FUNCTIONS_RECON_LOADED', true);
18
19
if (!defined('NEWBB_FUNCTIONS_RECON')) {
20
    define('NEWBB_FUNCTIONS_RECON', 1);
21
22
    /**
23
     * @param null $type
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $type is correct as it would always require null to be passed?
Loading history...
24
     * @return bool
25
     */
26
    function newbbSynchronization($type = null)
0 ignored issues
show
Unused Code introduced by
The parameter $type 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

26
    function newbbSynchronization(/** @scrutinizer ignore-unused */ $type = null)

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...
27
    {
28
        $allTypes = [
29
            'category',
30
            'forum',
31
            'topic',
32
            'post',
33
            'report',
34
            'rate',
35
            'moderate',
36
            'readtopic',
37
            'readforum',
38
            'stats',
39
        ];
40
        $type     = [];
41
        $type     = empty($type) ? $allTypes : (is_array($type) ? $type : [$type]);
0 ignored issues
show
introduced by
The condition is_array($type) is always true.
Loading history...
42
        foreach ($type as $item) {
43
            $handler = \XoopsModules\Newbb\Helper::getInstance()->getHandler($item);
44
            if ('stats' !== $item) {
45
                $handler->synchronization();
0 ignored issues
show
Bug introduced by
The method synchronization() 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

45
                $handler->/** @scrutinizer ignore-call */ 
46
                          synchronization();
Loading history...
46
            } else {
47
                $handler->reset();
0 ignored issues
show
Bug introduced by
The method reset() 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

47
                $handler->/** @scrutinizer ignore-call */ 
48
                          reset();
Loading history...
48
            }
49
50
            if (method_exists($handler, 'cleanExpires')) {
51
                $handler->cleanExpires();
52
            }
53
            if (method_exists($handler, 'clearGarbage')) {
54
                $handler->clearGarbage();
55
            }
56
            unset($handler);
57
        }
58
59
        return true;
60
    }
61
}
62