Passed
Push — master ( 17c747...646a8a )
by Michael
02:30
created

b_waiting_wgtransifex()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 29
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 19
c 1
b 0
f 1
nc 4
nop 0
dl 0
loc 29
rs 9.6333
1
<?php
2
/*************************************************************************/
3
4
# Waiting Contents Extensible                                            #
5
# Plugin for module wgTransifex                                            #
6
#                                                                        #
7
# Author                                                                 #
8
# goffy - wedega - Webdesign Gabor - [email protected]                #
9
#                                                                        #
10
# Last modified on 27.08.2020                                            #
11
/*************************************************************************/
12
/**
13
 * @return array
14
 */
15
 
16
use XoopsModules\Wgtransifex\Constants;
0 ignored issues
show
Bug introduced by
The type XoopsModules\Wgtransifex\Constants 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...
17
18
/**
19
 * @return array
20
 */
21
function b_waiting_wgtransifex()
22
{
23
    /** @var \XoopsMySQLDatabase $xoopsDB */
24
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
25
    $ret     = [];
26
    
27
    // packages notified as broken
28
    $block  = [];
29
    $sql    = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wgtransifex_packages') . ' WHERE pkg_status=' . Constants::STATUS_BROKEN;
30
    $result = $xoopsDB->query($sql);
31
    if ($result) {
32
        $block['adminlink'] = XOOPS_URL . '/modules/wgtransifex/admin/packages.php';
33
        [$block['pendingnum']] = $xoopsDB->fetchRow($result);
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type true; however, parameter $result of XoopsMySQLDatabase::fetchRow() does only seem to accept mysqli_result, maybe add an additional type check? ( Ignorable by Annotation )

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

33
        [$block['pendingnum']] = $xoopsDB->fetchRow(/** @scrutinizer ignore-type */ $result);
Loading history...
34
        $block['lang_linkname'] = _PI_WAITING_BROKENS;
35
    }
36
    $ret[] = $block;
37
    
38
    // waiting requests for new language packages
39
    $block  = [];
40
    $sql    = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wgtransifex_requests') . ' WHERE req_status=' . Constants::STATUS_PENDING;
41
    $result = $xoopsDB->query($sql);
42
    if ($result) {
43
        $block['adminlink'] = XOOPS_URL . '/modules/wgtransifex/admin/requests.php';
44
        [$block['pendingnum']] = $xoopsDB->fetchRow($result);
45
        $block['lang_linkname'] = _PI_WAITING_REQUESTS;
46
    }
47
    $ret[] = $block;
48
49
    return $ret;
50
}
51