Conditions | 4 |
Paths | 4 |
Total Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
22 | public function assets($path) |
||
23 | { |
||
24 | $file = base_path(trim(config('pwa.resources_path'), '/').'/'.urldecode($path)); |
||
25 | |||
26 | if (File::exists($file)) { |
||
27 | switch ($extension = pathinfo($file, PATHINFO_EXTENSION)) { |
||
|
|||
28 | case 'js': |
||
29 | $mimeType = 'text/javascript'; |
||
30 | break; |
||
31 | case 'css': |
||
32 | $mimeType = 'text/css'; |
||
33 | break; |
||
34 | default: |
||
35 | $mimeType = File::mimeType($file); |
||
36 | break; |
||
37 | } |
||
38 | |||
39 | $response = Response::make(File::get($file), 200); |
||
40 | $response->header('Content-Type', $mimeType); |
||
41 | $response->setSharedMaxAge(31536000); |
||
42 | $response->setMaxAge(31536000); |
||
43 | $response->setExpires(new \DateTime('+1 year')); |
||
44 | |||
45 | return $response; |
||
46 | } |
||
47 | |||
48 | return response('', 404); |
||
49 | } |
||
50 | } |
||
51 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.