mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-13 03:44:36 +02:00
Fixed code style.
This commit is contained in:
parent
1aed1d1d26
commit
9a7223a301
142 changed files with 534 additions and 716 deletions
|
@ -21,7 +21,6 @@
|
|||
|
||||
namespace App\Services;
|
||||
|
||||
|
||||
use App\Entity\Attachments\Attachment;
|
||||
|
||||
class FAIconGenerator
|
||||
|
@ -42,19 +41,21 @@ class FAIconGenerator
|
|||
|
||||
/**
|
||||
* Gets the Font awesome icon class for a file with the specified extension.
|
||||
* For example 'pdf' gives you 'fa-file-pdf'
|
||||
* For example 'pdf' gives you 'fa-file-pdf'.
|
||||
*
|
||||
* @param string $extension The file extension (without dot). Must be ASCII chars only!
|
||||
*
|
||||
* @return string The fontawesome class with leading 'fa-'
|
||||
*/
|
||||
public function fileExtensionToFAType(string $extension) : string
|
||||
public function fileExtensionToFAType(string $extension): string
|
||||
{
|
||||
if ($extension === '') {
|
||||
if ('' === $extension) {
|
||||
throw new \InvalidArgumentException('You must specify an extension!');
|
||||
}
|
||||
//Normalize file extension
|
||||
$extension = strtolower($extension);
|
||||
foreach (self::EXT_MAPPING as $fa => $exts) {
|
||||
if (in_array($extension, $exts, true)) {
|
||||
if (\in_array($extension, $exts, true)) {
|
||||
return $fa;
|
||||
}
|
||||
}
|
||||
|
@ -65,13 +66,15 @@ class FAIconGenerator
|
|||
|
||||
/**
|
||||
* Returns HTML code to show the given fontawesome icon.
|
||||
* E.g. <i class="fas fa-file-text"></i>
|
||||
* E.g. <i class="fas fa-file-text"></i>.
|
||||
*
|
||||
* @param string $icon_class The icon which should be shown (e.g. fa-file-text)
|
||||
* @param string $style The style of the icon 'fas'
|
||||
* @param string $options Any other css class attributes like size, etc.
|
||||
* @param string $style The style of the icon 'fas'
|
||||
* @param string $options Any other css class attributes like size, etc.
|
||||
*
|
||||
* @return string The final html
|
||||
*/
|
||||
public function generateIconHTML(string $icon_class, string $style = 'fas', string $options = '') : string
|
||||
public function generateIconHTML(string $icon_class, string $style = 'fas', string $options = ''): string
|
||||
{
|
||||
//XSS protection
|
||||
$icon_class = htmlspecialchars($icon_class);
|
||||
|
@ -85,4 +88,4 @@ class FAIconGenerator
|
|||
$options
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue