Gets a parser for a given file extension

@param   string  $extension
@return  object
@throws  UnsupportedFormatException  If `$extension` is an unsupported file format
192845
protected function getParser($extension)
	{
		$parser = null;

		$extension = strtolower($extension);

		foreach (Processor::all() as $fileParser)
		{
			if (in_array($extension, $fileParser->getSupportedExtensions()))
			{
				$parser = $fileParser;
				break;
			}
		}

		// If none exist, then throw an exception
		if ($parser === null)
		{
			throw new UnsupportedFormatException(sprintf('Unsupported configuration format "%s"', $extension));
		}

		return $parser;
	}
925502
public function resolveFilename($extension = null)
    {
        if ($extension === null) {
            $extension = $this->extension;
        }
        return $this->name . '-' . $this->id . '.' . $extension;
    }
1186727
public function getExtensionInstance($extension)
    {
        $instances = $this->getExtensionInstances();
        if (array_key_exists($extension, $instances)) {
            return $instances[$extension];
        }
        // in case Injector has been used to replace an extension
        foreach ($instances as $instance) {
            if (is_a($instance, $extension)) {
                return $instance;
            }
        }
        return null;
    }
533932
public static function purifyExtension($extension)
    {
        $extension = (string)$extension;
        $extension = trim($extension);
        $extension = ltrim($extension, '.');

        return $extension;
    }
297389
public static function for_extensions($extensions)
    {
        foreach ($extensions as $extension) {
            if ($formatter = self::for_extension($extension)) {
                return $formatter;
            }
        }

        return false;
    }
887546
public ResourceFormatParser getParserForFileExtension(final File file) throws UnsupportedFormatException {
        String extension = getFileExtension(file.getName());
        if (null != extension) {
            return getParserForFileExtension(extension);
        } else {
            throw new UnsupportedFormatException("Could not determine format for file: " + file.getAbsolutePath());
        }
    }
324121
public function setExtension($extension)
    {
        if (! Str::startsWith($extension, '.')) {
            $extension = ".$extension";
        }

        $this->extension = $extension;

        return $this;
    }
339474
public function getMimeType($extension)
    {
        if (isset($this->mimeTypes['.'.strtolower($extension)])) {
            return $this->mimeTypes['.'.strtolower($extension)];
        }

        return 'text/plain';
    }
268626
public function setFileExtension($extension)
  {
    if ($this->hasFileName()) {
      $a = explode('.', $this->getFileName(true));
      if (count($a) >= 2) {
        array_pop($a);
      }
      $a[]             = $extension;
      $this->file_name = join('.', $a);
    } else {
      $this->file_name = array_pop($this->arguments) . '.' . $extension;
    }

    return $this;
  }
1066152
protected function getImageSizeByExtension($file, $extension)
	{
		$extension = strtolower($extension);
		$this->loadExtension($extension);
		if (isset($this->classMap[$extension]))
		{
			$this->classMap[$extension]->getSize($file);
		}
	}
237375
private static function get_mime_type($extension) {
		$mime_type = '';
		switch ($extension) {
			case 'htm' :
			case 'html': $mime_type = 'text/html';
			             break;

			case 'css' : $mime_type = 'text/css';
			             break;

			case 'ico' : $mime_type = 'image/x-icon';
			             break;

			case 'js'  : $mime_type = 'text/javascript';
			             break;

			case 'png' : $mime_type = 'image/png';
			             break;

			case 'gif' : $mime_type = 'image/gif';
			             break;

			case 'jpg' :
			case 'jpeg': $mime_type = 'image/jpeg';
			             break;

			case 'pdf' : $mime_type = 'application/pdf';
						 break;

			case 'txt' : $mime_type = 'text/plain';
						 break;

			case 'svg' : $mime_type = 'image/svg+xml';
						 break;

			default    : $mime_type = 'application/octet-stream';
		}

		return $mime_type;
	}
187848
public function setExtension($extension = null)
    {
        if (!$extension) {
            $this->_path['extension'] = null;
        } else {
            $this->_path['extension'] = (string) trim($extension, '.');
        }

        return $this;
    }
172941
public static function getInstance($extension, $options = array())
	{
		$hash = md5($extension . serialize($options));

		if (isset(self::$instances[$hash]))
		{
			return self::$instances[$hash];
		}

		$parts = explode('.', $extension);
		$component = 'com_' . strtolower($parts[0]);
		$section = count($parts) > 1 ? $parts[1] : '';
		$classname = ucfirst(substr($component, 4)) . ucfirst($section) . 'Categories';

		if (!class_exists($classname))
		{
			$path = JPATH_SITE . '/components/' . $component . '/helpers/category.php';

			if (is_file($path))
			{
				include_once $path;
			}
			else
			{
				return false;
			}
		}

		self::$instances[$hash] = new $classname($options);

		return self::$instances[$hash];
	}
239535
protected function getParser($extension)
    {
        foreach ($this->supportedParsers as $parser) {
            if (in_array($extension, $parser::getSupportedExtensions())) {
                return new $parser();
            }
        }

        // If none exist, then throw an exception
        throw new UnsupportedFormatException('Unsupported configuration format');
    }
658933
private function getAllowedConverter($extension = null)
    {
        $allowedConverter = [
            ''     => ['pdf'],
            'pptx' => ['pdf'],
            'ppt'  => ['pdf'],
            'pdf'  => ['pdf'],
            'docx' => ['pdf', 'odt', 'html'],
            'doc'  => ['pdf', 'odt', 'html'],
            'wps'  => ['pdf', 'odt', 'html'],
            'dotx' => ['pdf', 'odt', 'html'],
            'docm' => ['pdf', 'odt', 'html'],
            'dotm' => ['pdf', 'odt', 'html'],
            'dot'  => ['pdf', 'odt', 'html'],
            'odt'  => ['pdf', 'html'],
            'xlsx' => ['pdf'],
            'xls'  => ['pdf'],
            'png'  => ['pdf'],
            'jpg'  => ['pdf'],
            'jpeg' => ['pdf'],
            'jfif' => ['pdf'],
            'PPTX' => ['pdf'],
            'PPT'  => ['pdf'],
            'PDF'  => ['pdf'],
            'DOCX' => ['pdf', 'odt', 'html'],
            'DOC'  => ['pdf', 'odt', 'html'],
            'WPS'  => ['pdf', 'odt', 'html'],
            'DOTX' => ['pdf', 'odt', 'html'],
            'DOCM' => ['pdf', 'odt', 'html'],
            'DOTM' => ['pdf', 'odt', 'html'],
            'DOT'  => ['pdf', 'odt', 'html'],
            'ODT'  => ['pdf', 'html'],
            'XLSX' => ['pdf'],
            'XLS'  => ['pdf'],
            'PNG'  => ['pdf'],
            'JPG'  => ['pdf'],
            'JPEG' => ['pdf'],
            'JFIF' => ['pdf'],
            'Pptx' => ['pdf'],
            'Ppt'  => ['pdf'],
            'Pdf'  => ['pdf'],
            'Docx' => ['pdf', 'odt', 'html'],
            'Doc'  => ['pdf', 'odt', 'html'],
            'Wps'  => ['pdf', 'odt', 'html'],
            'Dotx' => ['pdf', 'odt', 'html'],
            'Docm' => ['pdf', 'odt', 'html'],
            'Dotm' => ['pdf', 'odt', 'html'],
            'Dot'  => ['pdf', 'odt', 'html'],
            'Ddt'  => ['pdf', 'html'],
            'Xlsx' => ['pdf'],
            'Xls'  => ['pdf'],
            'Png'  => ['pdf'],
            'Jpg'  => ['pdf'],
            'Jpeg' => ['pdf'],
            'Jfif' => ['pdf'],
            'rtf'  => ['docx', 'txt']
        ];

        if ($extension !== null) {
            if (isset($allowedConverter[$extension])) {
                return $allowedConverter[$extension];
            }

            return [];
        }

        return $allowedConverter;
    }
680116
public function getHandler($extension)
	{
		if (isset($this->handlers[$extension]))
		{
			return $this->handlers[$extension];
		}

		$class = 'Fuel\Config\Handler\\'.ucfirst($extension);

		if ( ! class_exists($class, true))
		{
			throw new \RuntimeException('Could not find config handler for extension: '.$extension);
		}

		$handler = new $class;
		$this->handlers[$extension] = $handler;

		return $handler;
	}
843816
public function getOutExtension($extension)
    {
        if (isset($this->extensionMap[$extension])) {
            return $this->extensionMap[$extension];
        }

        return $extension;
    }