Completed
Push — master ( caa478...b65f01 )
by Manuel
02:41
created

mix.php ➔ mix()   C

Complexity

Conditions 7
Paths 28

Size

Total Lines 32
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 19
nc 28
nop 3
dl 0
loc 32
rs 6.7272
c 0
b 0
f 0
1
<?php
2
3
// mix('css/app.css')
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
4
// mix('js/app.js')
5
function mix($path, $json = false, $shouldHotReload = false)
6
{
7
    if (! $json) static $json;
8
    if (! $shouldHotReload) static $shouldHotReload;
9
10
    if (! $json) {
11
        $manifestPath = public_path('manifest.json');
12
        $shouldHotReload = file_exists(public_path('hot'));
13
14
        if (! file_exists($manifestPath)) {
15
            throw new Exception(
16
                'The Laravel Mix manifest file does not exist. ' .
17
                'Please run "npm run webpack" and try again.'
18
            );
19
        }
20
21
        $json = json_decode(file_get_contents($manifestPath), true);
22
    }
23
24
    $path = pathinfo($path, PATHINFO_BASENAME);
25
26
    if (! array_key_exists($path, $json)) {
27
        throw new Exception(
28
            'Unknown file path. Please check your requested ' .
29
            'webpack.mix.js output path, and try again.'
30
        );
31
    }
32
33
    return $shouldHotReload
34
        ? "http://localhost:8080{$json[$path]}"
35
        : url($json[$path]);
36
}
37