b_marquee_smartclient()   A
last analyzed

Complexity

Conditions 5
Paths 4

Size

Total Lines 28
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 19
c 0
b 0
f 0
nc 4
nop 3
dl 0
loc 28
rs 9.3222
1
<?php declare(strict_types=1);
2
/**
3
 * ****************************************************************************
4
 * marquee - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard (https://www.herve-thouzard.com)
6
 *
7
 * You may not change or alter any portion of this comment or credits
8
 * of supporting developers from this source code or any supporting source code
9
 * which is considered copyrighted (c) material of the original comment or credit authors.
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 *
14
 * @copyright         Hervé Thouzard (https://www.herve-thouzard.com)
15
 * @license           GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html)
16
 * @author            Hervé Thouzard (https://www.herve-thouzard.com)
17
 *
18
 * Version :
19
 * ****************************************************************************
20
 *
21
 * @param $limit
22
 * @param $dateFormat
23
 * @param $itemsSize
24
 *
25
 * @return array
26
 */
27
28
// Script to list recent clients from the smartclient module (tested with smartclient 1.02)
29
function b_marquee_smartclient($limit, $dateFormat, $itemsSize)
0 ignored issues
show
Unused Code introduced by
The parameter $dateFormat 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

29
function b_marquee_smartclient($limit, /** @scrutinizer ignore-unused */ $dateFormat, $itemsSize)

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...
30
{
31
    $block = [];
32
    if (!defined('SMARTCLIENT_DIRNAME')) {
33
        define('SMARTCLIENT_DIRNAME', 'smartclient');
34
    }
35
    require_once XOOPS_ROOT_PATH . '/modules/' . SMARTCLIENT_DIRNAME . '/include/common.php';
36
    // Creating the client handler object
37
    $clientHandler = smartclient_gethandler('client');
0 ignored issues
show
Bug introduced by
The function smartclient_gethandler was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

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

37
    $clientHandler = /** @scrutinizer ignore-call */ smartclient_gethandler('client');
Loading history...
38
    $clientsObj    = $clientHandler->getClients($limit, 0, _SCLIENT_STATUS_ACTIVE, 'title', 'ASC');
0 ignored issues
show
Bug introduced by
The constant _SCLIENT_STATUS_ACTIVE was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
39
    if ($clientsObj) {
40
        for ($i = 0, $iMax = count($clientsObj); $i < $iMax; ++$i) {
41
            if ($itemsSize > 0) {
42
                $title = xoops_substr($clientsObj[$i]->title(), 0, $itemsSize);
43
            } else {
44
                $title = $clientsObj[$i]->title();
45
            }
46
            $block[] = [
47
                'date'     => '',
48
                'category' => '',
49
                'author'   => '',
50
                'title'    => $title,
51
                'link'     => "<a href='" . XOOPS_URL . '/modules/smartclient/client.php?id=' . $clientsObj[$i]->id() . "'>" . $title . '</a>',
52
            ];
53
        }
54
    }
55
56
    return $block;
57
}
58