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

Assets::load()   B

Complexity

Conditions 5
Paths 16

Size

Total Lines 28
Code Lines 17

Duplication

Lines 7
Ratio 25 %

Importance

Changes 0
Metric Value
cc 5
eloc 17
nc 16
nop 0
dl 7
loc 28
rs 8.439
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 8 and the first side effect is on line 43.

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\Assets;
4
5
/**
6
 * Get paths for assets
7
 */
8
class Assets
9
{
10
    /**
11
     * Enqueue assets if files exist
12
     */
13
    public function load()
14
    {
15
        $vendorJsExists = file_exists(get_template_directory() . '/dist/js/vendor.js');
16
        $mainJsExists = file_exists(get_template_directory() . '/dist/js/main.js');
17
        $mainJsDependencies = [];
18
19
        $mainCssExists = file_exists(get_template_directory() . '/dist/css/main.css');
20
        $vendorCssExists = file_exists(get_template_directory() . '/dist/css/vendor.css');
21
        $mainCssDependencies = [];
22
23
        if ($vendorJsExists) {
24
            wp_enqueue_script('stashVendorJs', get_template_directory_uri() . '/dist/js/vendor.js', [], filemtime(get_stylesheet_directory() . '/dist/js/vendor.js'), true);
25
            array_push($mainJsDependencies, 'stashVendorJs');
26
        }
27
28
        if ($mainJsExists) {
29
            wp_enqueue_script('stashMainJs', get_template_directory_uri() . '/dist/js/main.js', $mainJsDependencies, filemtime(get_stylesheet_directory() . '/dist/js/main.js'), true);
30
        }
31
32 View Code Duplication
        if ($vendorCssExists) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
33
            wp_enqueue_style('stashVendorCss', get_template_directory_uri() . '/dist/css/vendor.css', [], filemtime(get_stylesheet_directory() . '/dist/css/vendor.css'));
34
            array_push($mainCssDependencies, 'stashVendorCss');
35
        }
36
37 View Code Duplication
        if ($mainCssExists) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
            wp_enqueue_style('stashMainCss', get_template_directory_uri() . '/dist/css/main.css', $mainCssDependencies, filemtime(get_stylesheet_directory() . '/dist/css/main.css'));
39
        }
40
    }
41
}
42
43
add_action('wp_enqueue_scripts', function () {
44
    $assets = new Assets();
45
    $assets->load();
46
}, 100);