GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 81a8a0...75582b )
by Vincent
11:02 queued 02:43
created

extras.php ➔ body_class()   B

Complexity

Conditions 7
Paths 6

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 8
nc 6
nop 1
dl 0
loc 16
rs 8.2222
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 27.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
namespace Undefined\Stash\Extras;
4
5
/**
6
 * Add <body> classes
7
 * @param $classes
8
 * @return array
9
 */
10
function body_class($classes)
11
{
12
    if (!is_archive() && !is_home()) {
13
        global $post;
0 ignored issues
show
Compatibility Best Practice introduced by
Use of global functionality is not recommended; it makes your code harder to test, and less reusable.

Instead of relying on global state, we recommend one of these alternatives:

1. Pass all data via parameters

function myFunction($a, $b) {
    // Do something
}

2. Create a class that maintains your state

class MyClass {
    private $a;
    private $b;

    public function __construct($a, $b) {
        $this->a = $a;
        $this->b = $b;
    }

    public function myFunction() {
        // Do something
    }
}
Loading history...
14
        $classes[] = get_post($post)->post_name;
15
    }
16
17
    // Add page slug if it doesn't exist
18
    if (is_single() || is_page() && !is_front_page()) {
19
        if (!in_array(basename(get_permalink()), $classes)) {
20
            $classes[] = basename(get_permalink());
21
        }
22
    }
23
24
    return $classes;
25
}
26
27
add_filter('body_class', __NAMESPACE__ . '\\body_class');
28
29
/**
30
 * Clean up the_excerpt()
31
 */
32
function excerpt_more()
33
{
34
    return ' &hellip; <a href="' . get_permalink() . '">' . __('Continued', 'stash') . '</a>';
35
}
36
37
add_filter('excerpt_more', __NAMESPACE__ . '\\excerpt_more');
38
39
function dd($var)
40
{
41
    echo '<pre>';
42
    var_dump($var);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($var); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
43
    die();
0 ignored issues
show
Coding Style Compatibility introduced by
The function dd() contains an exit expression.

An exit expression should only be used in rare cases. For example, if you write a short command line script.

In most cases however, using an exit expression makes the code untestable and often causes incompatibilities with other libraries. Thus, unless you are absolutely sure it is required here, we recommend to refactor your code to avoid its usage.

Loading history...
44
}