/** * Processes the provided path. * * @param $path * @return mixed */ public function processPath($path) { $path = $this->replaceDoubleOpeningBrackets($path); $path = $this->convertSingleOpeningSquareBracketsToPipes($path); $path = $this->replaceBracketEscapeSequenceWithSingleOpeningBrackets($path); $this->constructPathNameLexer(); $path = $this->templateRenderer->renderString($path); $this->restoreOriginalLexer(); $path = $this->removeUnwantedCharactersFromString($path); return $path; }
/** * Adds a single path to the underlying collectors and tree generators. * * This method will add all processed paths to the internal collection. * Additionally, it will return the array of paths that were processed * during the current invocation. * * @param $path * @throws \NewUp\Exceptions\InvalidPathException * @return array */ private function addPath($path) { $paths = $this->analyzer->analyze($path); $newPaths = []; foreach ($paths as $filePath) { $newPathInformation = $filePath; $newPathInformation['original'] = $filePath['path']; if ($this->getCollectorValue($filePath['path']) !== null) { // If the value from the collector is not null, we need to process the path value // using the template renderer. $newPathInformation['path'] = $this->templateRenderer->renderString($this->getCollectorValue($filePath['path'])); } else { // If the value IS null, we need to process the path value using the path parser. $newPathInformation['path'] = $this->parser->processPath($filePath['path']); } $newPaths[] = $newPathInformation; $this->paths[] = $newPathInformation; // Add the new file path association to the collector. $this->addRawToCollector($filePath['path'], $newPathInformation['path']); } $this->templateRenderer->addPath($path); return $newPaths; }