['-windows', '-win', ''], 'Darwin' => ['-macos', '-unix', ''], 'Linux' => ['-linux', '-unix', ''], default => throw new WrongUsageException('OS ' . PHP_OS_FAMILY . ' is not supported'), }; foreach ($m_key as $v) { if (isset(self::$lib[$name][$key . $v])) { return self::$lib[$name][$key . $v]; } } return $default; } if ($key !== null) { return self::$lib[$name][$key] ?? $default; } return self::$lib[$name]; } /** * @throws FileSystemException */ public static function getLibs(): array { if (self::$lib === null) { self::$lib = FileSystem::loadConfigArray('lib'); } return self::$lib; } /** * @throws FileSystemException * @throws RuntimeException * @throws WrongUsageException */ public static function getExt(string $name, ?string $key = null, mixed $default = null) { if (self::$ext === null) { self::$ext = FileSystem::loadConfigArray('ext'); } if (!isset(self::$ext[$name])) { throw new WrongUsageException('ext [' . $name . '] is not supported yet'); } $supported_sys_based = ['lib-depends', 'lib-suggests', 'ext-depends', 'ext-suggests', 'arg-type']; if ($key !== null && in_array($key, $supported_sys_based)) { $m_key = match (PHP_OS_FAMILY) { 'Windows' => ['-windows', '-win', ''], 'Darwin' => ['-macos', '-unix', ''], 'Linux' => ['-linux', '-unix', ''], default => throw new WrongUsageException('OS ' . PHP_OS_FAMILY . ' is not supported'), }; foreach ($m_key as $v) { if (isset(self::$ext[$name][$key . $v])) { return self::$ext[$name][$key . $v]; } } return $default; } if ($key !== null) { return self::$ext[$name][$key] ?? $default; } return self::$ext[$name]; } /** * @throws FileSystemException */ public static function getExts(): array { if (self::$ext === null) { self::$ext = FileSystem::loadConfigArray('ext'); } return self::$ext; } }