Passed
Push — master ( dcbd4a...4bb7b0 )
by Michael
02:37
created

smartclient.php ➔ b_marquee_smartclient()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 31
Code Lines 20

Duplication

Lines 5
Ratio 16.13 %

Importance

Changes 0
Metric Value
cc 5
eloc 20
nc 4
nop 3
dl 5
loc 31
rs 8.439
c 0
b 0
f 0
1
<?php
2
/**
3
 * ****************************************************************************
4
 * marquee - MODULE FOR XOOPS
5
 * Copyright (c) Hervé Thouzard (http://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 (http://www.herve-thouzard.com)
15
 * @license           http://www.fsf.org/copyleft/gpl.html GNU public license
16
 * @package           marquee
17
 * @author            Hervé Thouzard (http://www.herve-thouzard.com)
18
 *
19
 * Version :
20
 * ****************************************************************************
21
 *
22
 * @param $limit
23
 * @param $dateFormat
24
 * @param $itemsSize
25
 *
26
 * @return array
27
 */
28
29
// Script to list recent clients from the smartclient module (tested with smartclient 1.02)
30
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

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

39
    $clientHandler = /** @scrutinizer ignore-call */ smartclient_gethandler('client');
Loading history...
40
41
    $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...
42
    if ($clientsObj) {
43
        for ($i = 0, $iMax = count($clientsObj); $i < $iMax; ++$i) {
44
            if ($itemsSize > 0) {
45
                $title = xoops_substr($clientsObj[$i]->title(), 0, $itemsSize);
0 ignored issues
show
Bug introduced by
The function xoops_substr 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

45
                $title = /** @scrutinizer ignore-call */ xoops_substr($clientsObj[$i]->title(), 0, $itemsSize);
Loading history...
46
            } else {
47
                $title = $clientsObj[$i]->title();
48
            }
49
            $block[] = [
50
                'date'     => '',
51
                'category' => '',
52
                'author'   => '',
53
                'title'    => $title,
54
                'link'     => "<a href='" . XOOPS_URL . '/modules/smartclient/client.php?id=' . $clientsObj[$i]->id() . "'>" . $title . '</a>'
0 ignored issues
show
Bug introduced by
The constant XOOPS_URL was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
55
            ];
56
        }
57
    }
58
59
    return $block;
60
}
61