Returns an array of full path WURFL patches
@param array $patchElements array of SimpleXMLElement objects
@return array WURFL Patches
172546
private function wurflPatches($patchElements)
    {
        $patches = array();
        if ($patchElements) {
            foreach ($patchElements as $patchElement) {
                $patches[] = parent::getFullPath((string)$patchElement);
            }
        }
        return $patches;
    }
751719
private function createJavaScriptPaths(array $javascripts)
    {
        $files = array();

        foreach ($javascripts as $file) {
            if (!$this->isExternalJavaScriptFile($file)) {

                if (false !== strpos($file, '?')) {
                    $file = strstr($file, '?', true);
                }

                $file = $this->getBasePath() . $file;
            }

            $files[] = $file;
        }

        return $files;
    }
731781
public function getSegmentsExplode()
	{
		if ($this->_path === null)
			return [];

		$segments = explode('/', $this->_path);

		if (empty(end($segments)))
			array_pop($segments); // this normally indicates that the last character was a '/', which created an empty string in the last array member

		return $segments;
	}
796460
public function filterElements($elements){
        $this->elementsToSearch = is_array($elements) ? $elements : [$elements];
        foreach($this->elementsToSearch as $key=>$elementName){
            $this->parseElement($elementName);
        }
        return $this->parsedElements;
    }
411308
public static function replaceRelativePathElements($path)
    {
        $pathSegments = explode('/', $path);
        $absolutePath = '';
        foreach ($pathSegments as $pathSegment) {
            switch ($pathSegment) {
                case '.':
                    continue 2;
                break;
                case '..':
                    $absolutePath = NodePaths::getParentPath($absolutePath);
                break;
                default:
                    $absolutePath = NodePaths::addNodePathSegment($absolutePath, $pathSegment);
                break;
            }
        }

        return $absolutePath;
    }
1246713
protected function getLemmas(array $lemmas = [])
    {
        // Get folders
        $folders = $this->getPath($this->config('folders', []));

        foreach ($folders as $path) {
            if ($this->option('verbose')) {
                $this->line('    <info>' . $path . '</info>');
            }

            foreach ($this->getPhpFiles($path) as $php_file_path => $dumb) {
                $lemma = [];

                foreach ($this->extractTranslationFromFile($php_file_path) as $k => $v) {
                    $real_value = eval("return $k;");
                    $lemma[$real_value] = $php_file_path;
                }

                $lemmas = array_merge($lemmas, $lemma);
            }
        }

        if (count($lemmas) === 0) {
            $this->comment("No lemma have been found in the code.");
            $this->line("In these directories:");

            foreach ($this->config('folders', []) as $path) {
                $path = $this->getPath($path);
                $this->line("    {$path}");
            }

            $this->line("For these functions/methods:");

            foreach ($this->config('trans_methods', []) as $k => $v) {
                $this->line("    {$k}");
            }

            die();
        }

        $this->line((count($lemmas) > 1) ? count($lemmas)
            . " lemmas have been found in the code"
            : "1 lemma has been found in the code");

        if ($this->option('verbose')) {
            foreach ($lemmas as $key => $value) {
                if (strpos($key, '.') !== false) {
                    $this->line('    <info>' . $key . '</info> in file <comment>'
                        . $this->getShortPath($value) . '</comment>');
                }
            }
        }

        return $lemmas;
    }
913378
protected function convertToObject($arrayElements)
	{
		$objects = array();
		
		foreach ($arrayElements as $key => $value) {
			$object = new \stdClass();
			$object->name = $key;
			$object->value = $value;
			$objects[] = $object;
		}

		return $objects;
	}
1294885
public function createMap(...$paths)
    {
        $classes = [];

        $this->finder->files()
            ->ignoreUnreadableDirs()
            ->in($paths);

        foreach($this->excludePathPatterns as $exclude)
        {
            $this->finder->notPath($exclude);
        }

        foreach($this->inPathPatterns as $inPath)
        {
            $this->finder->path($inPath);
        }

        foreach($this->names as $name)
        {
            $this->finder->name($name);
        }

        /** @var SplFileInfo $file */
        foreach ($this->finder as $file) {
            $content = file_get_contents($file->getPathname());

            preg_match('^\s*class ([\S]*)\s*(extends|implements|{)^', $content, $match, PREG_OFFSET_CAPTURE);

            if (isset($match[1])) {
                $className = '\\'. trim($match[1][0]);
                $offset = $match[1][1];
            } else {
                continue;
            }

            preg_match('|\s*namespace\s*([\S]*)\s*;|', substr($content, 0 , $offset), $match);

            if (isset($match[1]) && trim($match[1]) !== '') {
                $className = '\\' . trim($match[1]) . $className;
            }

            if ($className !== '\\') {
                $classes[$file->getPathname()] = $className;
            }
        }

        return $classes;
    }
157751
public function getElementsForSearch()
    {
        $oldThemes = SSViewer::get_themes();
        SSViewer::set_themes(SSViewer::config()->get('themes'));
        try {
            $output = [];
            foreach ($this->owner->hasOne() as $key => $class) {
                if ($class !== ElementalArea::class) {
                    continue;
                }
                /** @var ElementalArea $area */
                $area = $this->owner->$key();
                if ($area) {
                    $output[] = strip_tags($area->forTemplate());
                }
            }
        } finally {
            // Reset theme if an exception occurs, if you don't have a
            // try / finally around code that might throw an Exception,
            // CMS layout can break on the response. (SilverStripe 4.1.1)
            SSViewer::set_themes($oldThemes);
        }
        return implode($output);
    }
341493
protected function elementToArray(\SimpleXMLElement $element): array
    {
        $result = [];
        foreach ($element->xpath('*') as $node) {
            if (count($node->xpath('*')) > 0) {
                $value = $this->elementToArray($node);
            } else {
                $value = strval($node);
            }
            $result = array_merge_recursive($result, [$node->getName() => $value]);
        }

        return $result;
    }
1018778
private function getPreparedPaths(array $paths): array
    {
        $fullPaths = [];

        foreach ($paths as $name => $path) {
            if (\is_array($path)) {
                foreach ($path as $p) {
                    $fullPaths[] = \rtrim($this->vendorDir . \DIRECTORY_SEPARATOR . $name . \DIRECTORY_SEPARATOR . $p, '/');
                }
            } else {
                $fullPaths[] = \rtrim($this->vendorDir . \DIRECTORY_SEPARATOR . $name . \DIRECTORY_SEPARATOR . $path, '/');
            }
        }

        return $fullPaths;
    }
276268
public function breadcrumbs(array $links) {

        $out = '<div class="breadcrumbs">' . "\n" . '<ol>' . "\n";
        foreach ($links as $url => $label) {
            $out .= "\t<li>{$this->view->htmlLink($url, $label)}</li>\n";
        }
        $out .= "</ol>\n</div>";
        return $out;
    }
900088
public function breadcrumbs($locations)
    {
        $trail = '';

        foreach ($locations as $location) {
            if (is_array($location)) {
                foreach ($location as $key => $value) {
                    $trail .= '<li class="breadcrumb-item"><a href="'.$value.'">'.ucfirst($key).'</a></li>';
                }
            } else {
                $trail .= '<li class="breadcrumb-item">'.ucfirst($location).'</li>';
            }
        }

        return $trail;
    }
191069
private function makeFileReports(\SimpleXMLElement $node)
    {
        $fileReports = array();
        /*
        * Most clover reports will have project/package/file/line xPath.
        * But there could be files that are not part of any package, i.e files that 
        * that do not declare namespace.
        */
        if ($node->file->count() > 0) {
            // so there is a file without package
            $fileReports = $this->makeFileReportsFromFiles($node->file, $fileReports);
        }
        if ($node->package->count() > 0) {
            $fileReports = $this->makeFileReportsFromPackages($node->package, $fileReports);
        }
        return $fileReports;
    }
489753
public function patch($device, $patchingDevice)
    {
        if (!$this->haveSameId($device, $patchingDevice)) {
            return $patchingDevice;
        }
        $groupIdCapabilitiesMap = WURFL_WURFLUtils::array_merge_recursive_unique($device->getGroupIdCapabilitiesMap(), $patchingDevice->getGroupIdCapabilitiesMap());
        return new WURFL_Xml_ModelDevice($device->id, $device->userAgent, $device->fallBack, $device->actualDeviceRoot, $device->specific, $groupIdCapabilitiesMap);
    }
455379
public function getNamespaceMappings()
	{
		$dom = (new XmlDocumentBuilder())->buildDocument($this);
		$xpath = new \DOMXPath($dom);
		
		$namespaces = [];
		
		foreach($xpath->query('namespace::*', $dom->documentElement) as $result)
		{
			$namespaces[(string)$result->prefix] = (string)$result->nodeValue;
		}
		
		return $namespaces;
	}
1282070
public function compile($patchs, $targetDocument = '{}')
    {
        foreach ($patchs as $patch) {
            try {
                $patch = new Patch($targetDocument, $patch);
                $targetDocument = $patch->apply();
            } catch (InvalidPatchDocumentJsonException $e) {
            } catch (InvalidTargetDocumentJsonException $e) {
            } catch (InvalidOperationException $e) {
            } catch (FailedTestException $e) {
            }
        }

        return json_decode($targetDocument);
    }