Commit bf0b86176822127fccce64c997ab7a7532b55e55
1 parent
2d8f1968
Exists in
master
by Eriksen: Refactoring de código
Showing
2 changed files
with
7 additions
and
15 deletions
Show diff stats
ieducar/lib/Utils/Mimetype.class.php
| ... | ... | @@ -81,37 +81,28 @@ |
| 81 | 81 | class Mimetype |
| 82 | 82 | { |
| 83 | 83 | |
| 84 | - function getType($filename) | |
| 84 | + public function getType($filename) | |
| 85 | 85 | { |
| 86 | - // get base name of the filename provided by user | |
| 87 | 86 | $filename = basename($filename); |
| 88 | - | |
| 89 | - // break file into parts seperated by . | |
| 90 | 87 | $filename = explode('.', $filename); |
| 91 | - | |
| 92 | - // take the last part of the file to get the file extension | |
| 93 | 88 | $filename = $filename[count($filename)-1]; |
| 94 | 89 | |
| 95 | - // find mime type | |
| 96 | 90 | return $this->privFindType($filename); |
| 97 | 91 | } |
| 98 | 92 | |
| 99 | - function privFindType($ext) | |
| 93 | + protected function privFindType($ext) | |
| 100 | 94 | { |
| 101 | - // create mimetypes array | |
| 102 | 95 | $mimetypes = $this->privBuildMimeArray(); |
| 103 | 96 | |
| 104 | - // return mime type for extension | |
| 105 | 97 | if (isset($mimetypes[$ext])) { |
| 106 | 98 | return $mimetypes[$ext]; |
| 107 | 99 | } |
| 108 | - // if the extension wasn't found return FALSE | |
| 109 | 100 | else { |
| 110 | 101 | return FALSE; |
| 111 | 102 | } |
| 112 | 103 | } |
| 113 | 104 | |
| 114 | - function privBuildMimeArray() { | |
| 105 | + protected function privBuildMimeArray() { | |
| 115 | 106 | return array( |
| 116 | 107 | 'doc' => 'application/msword', |
| 117 | 108 | 'odt' => 'application/vnd.oasis.opendocument.text', |
| ... | ... | @@ -120,4 +111,4 @@ class Mimetype |
| 120 | 111 | 'xls' => 'application/vnd.ms-excel', |
| 121 | 112 | ); |
| 122 | 113 | } |
| 123 | 114 | -} |
| 115 | +} | |
| 124 | 116 | \ No newline at end of file | ... | ... |
ieducar/tests/unit/FileStreamTest.class.php
| ... | ... | @@ -28,10 +28,11 @@ require_once 'Utils/Mimetype.class.php'; |
| 28 | 28 | |
| 29 | 29 | |
| 30 | 30 | /** |
| 31 | - * DownloadTest class. | |
| 31 | + * FileStreamTest class. | |
| 32 | 32 | * |
| 33 | 33 | * @author Eriksen Costa Paixăo <eriksen.paixao_bs@cobra.com.br> |
| 34 | 34 | * @license http://creativecommons.org/licenses/GPL/2.0/legalcode.pt CC GNU GPL |
| 35 | + * @link http://code.google.com/p/bovigo/wiki/vfsStream vfsStream project | |
| 35 | 36 | * @package Test |
| 36 | 37 | * @since Classe disponível desde a versăo 1.1.0 |
| 37 | 38 | * @version $Id$ |
| ... | ... | @@ -153,4 +154,4 @@ class FileStreamTest extends UnitBaseTest |
| 153 | 154 | @$fileStream->streamFile(); |
| 154 | 155 | } |
| 155 | 156 | |
| 156 | -} | |
| 157 | 157 | \ No newline at end of file |
| 158 | +} | ... | ... |