*/ public static function scandir(string $filepath):array { if (!is_dir($filepath) || ($output = scandir($filepath)) === false) { throw new MDFileDoesNotExist("There is no file {$filepath}"); } return array_values(array_diff($output, ['.', '..'])); } /** * Function checking if a string starts with another. * * @param string $haystack String to check. * @param string $needle Potential start of $haystack. * * @return boolean */ public static function startsWith(string $haystack, string $needle):bool { if (substr($haystack, 0, strlen($needle)) == $needle) return true; else return false; } /** * Function checking if a string starts with any input from the input array. * * @param string $haystack String to check. * @param string[] $needles Array containing potential start values of $haystack. * * @return boolean */ public static function startsWithAny(string $haystack, array $needles):bool { $output = false; foreach ($needles as $needle) { $output = self::startsWith($haystack, $needle); if ($output == true) return $output; } return $output; } }