Closed WinterSilence closed 9 years ago
Better move "mime" methods into separate class Mime. Also, it will reduce method names.
File::mime():
if ($file = getimagesize($filename)) { if (!empty($file['mime'])) { return $file['mime']; } }
faster than
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION)); if (preg_match('/^(?:jpe?g|png|[gt]if|bmp|swf)$/', $extension)) { $file = getimagesize($filename); if (!empty($file['mime'])) { return $file['mime']; } }
Also, in_array() faster than preg_match().
Wrong:
if (function_exists('finfo_open')) {
Correct
if (class_exists('finfo') && defined('FILEINFO_MIME_TYPE')) {
Simply save results of checks in properties:
if (ini_get('mime_magic.magicfile') && function_exists('mime_content_type')) {
Better move "mime" methods into separate class Mime. Also, it will reduce method names.
File::mime():
faster than
Also, in_array() faster than preg_match().
Wrong:
Correct
Simply save results of checks in properties: