mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-12 06:17:28 -08:00
Refactor big switch to lookup in array. A bit cleaner/codacy happier.
This commit is contained in:
parent
fe74394ae6
commit
4fef065010
|
@ -606,38 +606,32 @@ class Helper
|
||||||
|
|
||||||
$extension = substr(strrchr($filename,'.'),1);
|
$extension = substr(strrchr($filename,'.'),1);
|
||||||
|
|
||||||
if ($extension) {
|
$allowedExtensionMap = [
|
||||||
switch ($extension) {
|
// Images
|
||||||
case 'jpg':
|
'jpg' => 'fa fa-file-image-o',
|
||||||
case 'jpeg':
|
'jpeg' => 'fa fa-file-image-o',
|
||||||
case 'gif':
|
'gif' => 'fa fa-file-image-o',
|
||||||
case 'png':
|
'png' => 'fa fa-file-image-o',
|
||||||
return "fa fa-file-image-o";
|
// word
|
||||||
break;
|
'doc' => 'fa fa-file-word-o',
|
||||||
case 'doc':
|
'docx' => 'fa fa-file-word-o',
|
||||||
case 'docx':
|
// Excel
|
||||||
return "fa fa-file-word-o";
|
'xls' => 'fa fa-file-excel-o',
|
||||||
break;
|
'xlsx' => 'fa fa-file-excel-o',
|
||||||
case 'xls':
|
// archive
|
||||||
case 'xlsx':
|
'zip' => 'fa fa-file-archive-o',
|
||||||
return "fa fa-file-excel-o";
|
'rar' => 'fa fa-file-archive-o',
|
||||||
break;
|
//Text
|
||||||
case 'zip':
|
'txt' => 'fa fa-file-text-o',
|
||||||
case 'rar':
|
'rtf' => 'fa fa-file-text-o',
|
||||||
return "fa fa-file-archive-o";
|
'xml' => 'fa fa-file-text-o',
|
||||||
break;
|
// Misc
|
||||||
case 'pdf':
|
'pdf' => 'fa fa-file-pdf-o',
|
||||||
return "fa fa-file-pdf-o";
|
'lic' => 'fa fa-file-floppy-o',
|
||||||
break;
|
];
|
||||||
case 'txt':
|
|
||||||
return "fa fa-file-text-o";
|
if ($extension && array_key_exists($extension, $allowedExtensionMap)) {
|
||||||
break;
|
return $allowedExtensionMap[$extension];
|
||||||
case 'lic':
|
|
||||||
return "fa fa-floppy-o";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return "fa fa-file-o";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return "fa fa-file-o";
|
return "fa fa-file-o";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue