/** * @param File $file * @return ParserInterface * @throws \RuntimeException */ public function fromFile(File $file) { switch (true) { case $file->findLine('#^\\<phploc\\>$#'): return new PHPLoc($file); case $file->findLine('#^\\<checkstyle version="1.+$#'): return new Checkstyle($file); default: throw new \RuntimeException("No parser found for " . $file->getBasename()); } }