get($class, 'priority'); arsort($sortedClasses); self::$sorted_extractor_classes = $sortedClasses; } foreach(self::$sorted_extractor_classes as $className => $priority) { $formatter = new $className(); $matched = array_filter($formatter->supportedExtensions(), function($compare) use($extension) { return (strtolower($compare) == strtolower($extension)); }); if($matched) return $formatter; } } /** * Checks if the extractor is supported on the current environment, * for example if the correct binaries or libraries are available. * * @return boolean */ abstract function isAvailable(); /** * Return an array of content types that the extractor can handle. * @return unknown_type */ abstract function supportedExtensions(); /** * Given a file path, extract the contents as text. * * @param $path * @return unknown_type */ abstract function getContent($path); } class FileTextExtractor_Exception extends Exception {}