b_waiting_wggallery()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 28
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 28
rs 9.6333
1
<?php declare(strict_types=1);
2
3
# Waiting Contents Extensible                                            #
4
# Plugin for module wgGallery                                            #
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\Wggallery\Constants;
0 ignored issues
show
Bug introduced by
The type XoopsModules\Wggallery\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_wggallery()
21
{
22
    /** @var \XoopsMySQLDatabase $xoopsDB */
23
    $xoopsDB = \XoopsDatabaseFactory::getDatabaseConnection();
24
    $ret     = [];
25
    // images waiting for approvement
26
    $block  = [];
27
    $sql    = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wggallery_images') . ' WHERE img_state=' . Constants::STATE_APPROVAL_VAL;
28
    $result = $xoopsDB->query($sql);
29
    if ($result) {
30
        $block['adminlink'] = XOOPS_URL . '/modules/wggallery/admin/images.php';
31
        [$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

31
        [$block['pendingnum']] = $xoopsDB->fetchRow(/** @scrutinizer ignore-type */ $result);
Loading history...
32
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
33
    }
34
    $ret[] = $block;
35
36
    // albums waiting for approvement
37
    $block  = [];
38
    $sql    = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('wggallery_albums') . ' WHERE alb_state=' . Constants::STATE_APPROVAL_VAL;
39
    $result = $xoopsDB->query($sql);
40
    if ($result) {
41
        $block['adminlink'] = XOOPS_URL . '/modules/wggallery/admin/albums.php';
42
        [$block['pendingnum']] = $xoopsDB->fetchRow($result);
43
        $block['lang_linkname'] = _PI_WAITING_WAITINGS;
44
    }
45
    $ret[] = $block;
46
47
    return $ret;
48
}
49