Remove PEAR support from file type detection
[phorkie.git] / src / phorkie / Tool / MIME / Type / PlainDetect.php
1 <?php
2 namespace phorkie;
3
4 class Tool_MIME_Type_PlainDetect extends \MIME_Type_PlainDetect
5 {
6     /**
7      * Try to find the magic file copied by phing's build.xml into
8      * lib/data/.
9      *
10      * @return string path to the magic file
11      */
12     public static function getMagicFile()
13     {
14         $rootdir = __DIR__ . '/../../../../../';
15         $magicPath = $rootdir . '/lib/cweiske/mime_type_plaindetect/data/programming.magic';
16         if (!\Phar::running()) {
17             return $magicPath;
18         } else {
19             //magic file within a .phar does not work:
20             // https://bugs.php.net/bug.php?id=67556
21             //put it outside
22             $target = '/tmp/phorkie-programming.magic';
23             if (!file_exists($target)) {
24                 copy($magicPath, $target);
25             }
26             return $target;
27         }
28         return parent::getMagicFile();
29     }
30 }
31 ?>