From bf0b86176822127fccce64c997ab7a7532b55e55 Mon Sep 17 00:00:00 2001 From: Eriksen Costa Paixão Date: Fri, 17 Jul 2009 18:58:31 +0000 Subject: [PATCH] by Eriksen: Refactoring de código --- ieducar/lib/Utils/Mimetype.class.php | 17 ++++------------- ieducar/tests/unit/FileStreamTest.class.php | 5 +++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/ieducar/lib/Utils/Mimetype.class.php b/ieducar/lib/Utils/Mimetype.class.php index e09a641..62631b6 100644 --- a/ieducar/lib/Utils/Mimetype.class.php +++ b/ieducar/lib/Utils/Mimetype.class.php @@ -81,37 +81,28 @@ class Mimetype { - function getType($filename) + public function getType($filename) { - // get base name of the filename provided by user $filename = basename($filename); - - // break file into parts seperated by . $filename = explode('.', $filename); - - // take the last part of the file to get the file extension $filename = $filename[count($filename)-1]; - // find mime type return $this->privFindType($filename); } - function privFindType($ext) + protected function privFindType($ext) { - // create mimetypes array $mimetypes = $this->privBuildMimeArray(); - // return mime type for extension if (isset($mimetypes[$ext])) { return $mimetypes[$ext]; } - // if the extension wasn't found return FALSE else { return FALSE; } } - function privBuildMimeArray() { + protected function privBuildMimeArray() { return array( 'doc' => 'application/msword', 'odt' => 'application/vnd.oasis.opendocument.text', @@ -120,4 +111,4 @@ class Mimetype 'xls' => 'application/vnd.ms-excel', ); } -} +} \ No newline at end of file diff --git a/ieducar/tests/unit/FileStreamTest.class.php b/ieducar/tests/unit/FileStreamTest.class.php index 18860d0..278c269 100644 --- a/ieducar/tests/unit/FileStreamTest.class.php +++ b/ieducar/tests/unit/FileStreamTest.class.php @@ -28,10 +28,11 @@ require_once 'Utils/Mimetype.class.php'; /** - * DownloadTest class. + * FileStreamTest class. * * @author Eriksen Costa Paixão * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL + * @link http://code.google.com/p/bovigo/wiki/vfsStream vfsStream project * @package Test * @since Classe disponível desde a versão 1.1.0 * @version $Id$ @@ -153,4 +154,4 @@ class FileStreamTest extends UnitBaseTest @$fileStream->streamFile(); } -} \ No newline at end of file +} -- libgit2 0.21.2