/** * Helper to get instance of AutoloadRenderer with cli options applied * * @param CollectorResult $result * * @throws \RuntimeException * @return \TheSeer\Autoload\AutoloadRenderer|\TheSeer\Autoload\StaticRenderer */ public function getRenderer(CollectorResult $result) { $isStatic = $this->config->isStaticMode(); $isPhar = $this->config->isPharMode(); $isCompat = $this->config->isCompatMode(); $isOnce = $this->config->isOnceMode(); if ($isStatic === TRUE) { $renderer = new StaticRenderer($result->getUnits()); $renderer->setDependencies($result->getDependencies()); $renderer->setPharMode($isPhar); $renderer->setRequireOnce($isOnce); } else { $renderer = new AutoloadRenderer($result->getUnits()); if ($this->config->usePrepend()) { $renderer->prependAutoloader(); } if ($this->config->useExceptions()) { $renderer->enableExceptions(); } } $renderer->setCompat($isCompat); $basedir = $this->config->getBaseDirectory(); if (!$basedir || !is_dir($basedir)) { throw new \RuntimeException("Given basedir '{$basedir}' does not exist or is not a directory"); } $renderer->setBaseDir($basedir); $format = $this->config->getDateFormat(); if ($format) { $renderer->setDateTimeFormat($format); } $renderer->setIndent($this->config->getIndent()); $renderer->setLineBreak($this->config->getLinebreak()); foreach ($this->config->getVariables() as $name => $value) { $renderer->setVariable($name, $value); } return $renderer; }