Allow extension fileinfo strategy on windows
Allow extension fileinfo strategy on windows

<?php <?php
/** /**
* File mime type strategy guessing the file extension * File mime type strategy guessing the file extension
* *
* @author Christopher Han <xiphux@gmail.com> * @author Christopher Han <xiphux@gmail.com>
* @copyright Copyright (c) 2012 Christopher Han * @copyright Copyright (c) 2012 Christopher Han
* @package GitPHP * @package GitPHP
* @subpackage Git\FileMimeType * @subpackage Git\FileMimeType
*/ */
class GitPHP_FileMimeType_Extension implements GitPHP_FileMimeTypeStrategy_Interface class GitPHP_FileMimeType_Extension implements GitPHP_FileMimeTypeStrategy_Interface
{ {
/** /**
* Gets the mime type for a blob * Gets the mime type for a blob
* *
* @param GitPHP_Blob $blob blob * @param GitPHP_Blob $blob blob
* @return string mime type * @return string mime type
*/ */
public function GetMime($blob) public function GetMime($blob)
{ {
if (!$blob) if (!$blob)
return false; return false;
   
$file = $blob->GetName(); $file = $blob->GetName();
   
if (empty($file)) if (empty($file))
return ''; return '';
   
$dotpos = strrpos($file, '.'); $dotpos = strrpos($file, '.');
if ($dotpos !== FALSE) if ($dotpos !== FALSE)
$file = substr($file, $dotpos+1); $file = substr($file, $dotpos+1);
switch ($file) { switch ($file) {
case 'jpg': case 'jpg':
case 'jpeg': case 'jpeg':
case 'jpe': case 'jpe':
return 'image/jpeg'; return 'image/jpeg';
break; break;
case 'gif': case 'gif':
return 'image/gif'; return 'image/gif';
break; break;
case 'png'; case 'png';
return 'image/png'; return 'image/png';
break; break;
} }
   
return ''; return '';
} }
   
/** /**
* Gets whether this mimetype strategy is valid * Gets whether this mimetype strategy is valid
* *
* @return bool true if valid * @return bool true if valid
*/ */
public function Valid() public function Valid()
{ {
return !GitPHP_Util::IsWindows(); return true;
} }
   
} }
   
comments