Created
November 3, 2011 23:30
-
-
Save TiuTalk/1338259 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Classe para fazer verificações de tipos de arquivos | |
*/ | |
class FileType { | |
/** | |
* Lista de extensões válidas para imagens | |
* | |
* @var array | |
*/ | |
public static $image = array('jpg', 'png', 'gif'); | |
/** | |
* Lista de extensões válidas para documentos | |
* | |
* @var array | |
*/ | |
public static $doc = array('doc', 'docx'); | |
/** | |
* Verifica se o tipo de arquivo (extensão) está dentro de uma lista válida | |
* | |
* @param string $type Tipo de arquivo (extensão) | |
* @param array $list Lista de extensões válidas | |
* | |
* @return boolean | |
*/ | |
public static function isTypeInList($type, $list) { | |
return in_array($type, $list); | |
} | |
/** | |
* Verifica se o tipo de arquivo (extensão) é uma imagem | |
* | |
* @param string $type Tipo de arquivo (extensão) | |
* | |
* @return boolean | |
*/ | |
public static function isImage($type) { | |
return self::isTypeInList($type, self::$image); | |
} | |
/** | |
* Verifica se o tipo de arquivo (extensão) é um documento | |
* | |
* @param string $type Tipo de arquivo (extensão) | |
* | |
* @return boolean | |
*/ | |
public static function isDoc($type) { | |
return self::isTypeInList($type, self::$doc); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment