Failed Conditions
Pull Request — master (#222)
by
unknown
14:39 queued 09:48
created

smarty_function_defaultsort()   A

Complexity

Conditions 6
Paths 6

Size

Total Lines 22
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 22
rs 9.2222
c 1
b 0
f 0
cc 6
nc 6
nop 2
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 * ACC Development Team. Please see team.json for a list of contributors.     *
5
 *                                                                            *
6
 * This is free and unencumbered software released into the public domain.    *
7
 * Please see LICENSE.md for the full licencing statement.                    *
8
 ******************************************************************************/
9
10
/**
11
 * Sets up the cookie-based default sorting on request tables
12
 *
13
 * @param                          $params
14
 * @param Smarty_Internal_Template $template
15
 *
16
 * @return string
17
 */
18
function smarty_function_defaultsort($params, Smarty_Internal_Template $template)
0 ignored issues
show
Unused Code introduced by
The parameter $template 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

18
function smarty_function_defaultsort($params, /** @scrutinizer ignore-unused */ Smarty_Internal_Template $template)

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...
Bug introduced by
The type Smarty_Internal_Template 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...
19
{
20
    if (empty($params['id'])) {
21
        return "";
22
    }
23
24
    $attr = 'data-sortname="' . htmlspecialchars($params['id'], ENT_QUOTES) . '"';
25
26
    if (empty($params['req'])) {
27
        return $attr;
28
    }
29
30
    if ($params['dir'] !== 'asc' && $params['dir'] !== 'desc') {
31
        $params['dir'] = 'asc';
32
    }
33
34
    $sort = '';
35
    if ($params['req'] === $params['id']) {
36
        $sort = ' data-defaultsort="' . htmlspecialchars($params['dir'], ENT_QUOTES) . '"';
37
    }
38
39
    return $attr . $sort;
40
}