mirror of
https://github.com/Universal-Omega/PortableInfobox.git
synced 2024-11-15 20:09:44 +00:00
DAT-2895 Address CR remarks; Simplify trim call and returning of value
This commit is contained in:
parent
df3966be4e
commit
ad12549cb8
|
@ -70,24 +70,23 @@ class ImageFilenameSanitizer {
|
|||
// strip HTML tags
|
||||
$filename = strip_tags( $filename );
|
||||
// replace the surrounding whitespace
|
||||
$filename = trim( $filename, "\t\n\r" );
|
||||
$filename = trim( $filename );
|
||||
return $filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $potentialFilename
|
||||
* @param $filePrefixRegex
|
||||
* @return null
|
||||
* @return string|null
|
||||
*/
|
||||
private function extractFilename( $potentialFilename, $filePrefixRegex ) {
|
||||
$trimmedFilename = trim( $potentialFilename, "[]" );
|
||||
$unprefixedFilename = mb_ereg_replace( $filePrefixRegex, "", $trimmedFilename );
|
||||
$filenameParts = explode( '|', $unprefixedFilename );
|
||||
if ( !empty( $filenameParts[0] ) ) {
|
||||
$filename = $filenameParts[0];
|
||||
} else {
|
||||
$filename = null;
|
||||
return $filenameParts[0];
|
||||
}
|
||||
return $filename;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue