targetArchitecture == TargetDescriptionFile::ARCHITECTURE_AVR8) { $tdf = new Avr8TargetDescriptionFile($filePath); } return $tdf; } /** * Loads all AVR8 target description files. * * @return Avr8TargetDescriptionFile[] */ public static function loadAvr8Tdfs(): array { /** @var Avr8TargetDescriptionFile[] $output */ $output = []; foreach (self::loadXmlFiles(self::AVR8_TDF_PATH) as $xmlFile) { $output[] = new Avr8TargetDescriptionFile($xmlFile->getPathname()); } return $output; } /** * Recursively loads all XML files from a given directory. * * @param string $dirPath * @return \SplFileInfo[] */ private static function loadXmlFiles(string $dirPath): array { $output = []; $directory = new \DirectoryIterator($dirPath); foreach ($directory as $entry) { if ($entry->isFile() && $entry->getExtension() == 'xml') { $output[] = clone $entry; } else if ($entry->isDir() && !$entry->isDot()) { $output = array_merge($output, self::loadXmlFiles($entry->getPathname())); } } return $output; } }