parserMap[$parser->getType()] = $parser; } /** * Get the parser for a given type * * @param string $type The parser type to retrieve * * @return ParserInterface * * @since 2.0.0-alpha */ public function get(string $type): ParserInterface { if (!$this->has($type)) { throw new \InvalidArgumentException(sprintf('There is not a parser registered for the `%s` type.', $type)); } return $this->parserMap[$type]; } /** * Check if a parser is registered for the given type * * @param string $type The parser type to check (typically the file extension) * * @return boolean * * @since 2.0.0-alpha */ public function has(string $type): bool { return isset($this->parserMap[$type]); } }