public static function listFilesRecursively(string $directory, bool $absolutePath = true, string ...$extensions): array
    {
        $paths = array();
        if (!is_dir($directory)) {
            return $paths;
        }
        
        $directoryIterator = new \RecursiveDirectoryIterator($directory);
        $recursiveIterator = new \RecursiveIteratorIterator($directoryIterator, \RecursiveIteratorIterator::SELF_FIRST);
        
        foreach ($recursiveIterator as $file) {
            if (!empty($extensions) && !in_array('.' . $file->getExtension(), $extensions)) {
                continue;
            }
            
            $path = $file->getPathName();
            if (!$absolutePath) {
                $path = substr($path, strlen($directory));
            }
            
            $paths[] = $path;
        }
        
        return $paths;
    }