Пример #1
0
 /**
  * Return the MIME content type from the given file name.
  *
  * @param string $fileName The file name.
  * @param string $default The default MIME type to return for unknown extensions
  * @return string
  */
 public static function getContentTypeFromFileName($fileName, $default = 'application/octet-stream')
 {
     if (empty($fileName)) {
         return $default;
     }
     $ext = pathinfo($fileName, PATHINFO_EXTENSION);
     switch ($ext) {
         case 'ini':
             return IniTreeSerializer::getContentType();
         case 'json':
             return JsonTreeSerializer::getContentType();
         case 'php':
             return PhpTreeSerializer::getContentType();
         case 'xml':
             return XmlTreeSerializer::getContentType();
         case 'yml':
             return YmlTreeSerializer::getContentType();
         default:
             return $default;
     }
 }
 /**
  * @expectedException \Exception
  */
 public function testYmlDeserializeNotImplementedException()
 {
     YmlTreeSerializer::deserialize('');
 }