b_waiting_wgtransifex()   A
last analyzed

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 declare(strict_types=1);
2
3
# Waiting Contents Extensible                                            #
4
# Plugin for module wgTransifex                                            #
5
#                                                                        #
6
# Author                                                                 #
7
# goffy - wedega - Webdesign Gabor - [email protected]                #
8
#                                                                        #
9
# Last modified on 27.08.2020                                            #
10
11
/**
12
 * @return array
13
 */
14
15
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...
16
17
/**
18
 * @return array
19
 */
20
function b_waiting_wgtransifex()
21
{
22
    /** @var \XoopsMySQLDatabase $xoopsDB */
23
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
24
    $ret     = [];
25
26
    // packages notified as broken
27
    $block  = [];
28
    $sql    = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wgtransifex_packages') . ' WHERE pkg_status=' . Constants::STATUS_BROKEN;
29
    $result = $xoopsDB->query($sql);
30
    if ($result) {
31
        $block['adminlink'] = XOOPS_URL . '/modules/wgtransifex/admin/packages.php';
32
        [$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

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