From 8770d0aea1e95feb5a8ddfba3e12cb073b73274f Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Sun, 26 Jun 2011 12:28:48 -0500 Subject: [PATCH] tweaked File::is method. --- system/file.php | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/system/file.php b/system/file.php index 8ed386db..24402dc4 100644 --- a/system/file.php +++ b/system/file.php @@ -136,25 +136,6 @@ class File { return file_put_contents($path, $data, LOCK_EX | FILE_APPEND); } - /** - * Determine if a file is a given type. - * - * The Fileinfo PHP extension will be used to determine the MIME - * type of the file. Any extension in the File::$mimes array may - * be passed as a type. - */ - public static function is($extension, $path) - { - if ( ! array_key_exists($extension, static::$mimes)) - { - throw new \Exception("File extension [$extension] is unknown. Cannot determine file type."); - } - - $mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path); - - return (is_array(static::$mimes[$extension])) ? in_array($mime, static::$mimes[$extension]) : $mime === static::$mimes[$extension]; - } - /** * Extract the extension from a file path. * @@ -183,6 +164,25 @@ class File { return $default; } + /** + * Determine if a file is a given type. + * + * The Fileinfo PHP extension will be used to determine the MIME + * type of the file. Any extension in the File::$mimes array may + * be passed as a type. + */ + public static function is($extension, $path) + { + if ( ! array_key_exists($extension, static::$mimes)) + { + throw new \Exception("File extension [$extension] is unknown. Cannot determine file type."); + } + + $mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path); + + return (is_array(static::$mimes[$extension])) ? in_array($mime, static::$mimes[$extension]) : $mime === static::$mimes[$extension]; + } + /** * Create a response that will force a file to be downloaded. *