芝麻web文件管理V1.00
编辑当前文件:/home/mgatv524/public_html/edurocha/vendor/ralouphie/mimey/src/MimeTypes.php
* array( * 'extensions' => array( * 'application/json' => array('json'), * 'image/jpeg' => array('jpg', 'jpeg'), * ... * ), * 'mimes' => array( * 'json' => array('application/json'), * 'jpeg' => array('image/jpeg'), * ... * ) * ) * */ public function __construct($mapping = null) { if ($mapping === null) { $this->mapping = self::getBuiltIn(); } else { $this->mapping = $mapping; } } /** * @inheritdoc */ public function getMimeType($extension) { $extension = $this->cleanInput($extension); if (!empty($this->mapping['mimes'][$extension])) { return $this->mapping['mimes'][$extension][0]; } return null; } /** * @inheritdoc */ public function getExtension($mime_type) { $mime_type = $this->cleanInput($mime_type); if (!empty($this->mapping['extensions'][$mime_type])) { return $this->mapping['extensions'][$mime_type][0]; } return null; } /** * @inheritdoc */ public function getAllMimeTypes($extension) { $extension = $this->cleanInput($extension); if (isset($this->mapping['mimes'][$extension])) { return $this->mapping['mimes'][$extension]; } return array(); } /** * @inheritdoc */ public function getAllExtensions($mime_type) { $mime_type = $this->cleanInput($mime_type); if (isset($this->mapping['extensions'][$mime_type])) { return $this->mapping['extensions'][$mime_type]; } return array(); } /** * Get the built-in mapping. * * @return array The built-in mapping. */ protected static function getBuiltIn() { if (self::$built_in === null) { self::$built_in = require(dirname(__DIR__) . '/mime.types.php'); } return self::$built_in; } /** * Normalize the input string using lowercase/trim. * * @param string $input The string to normalize. * * @return string The normalized string. */ private function cleanInput($input) { return strtolower(trim($input)); } }