public static function renameInZip(ZipArchive $zipArchive, $oldname, $newname)
    {
        $i = 0;
        $renameCount = 0;

        while (($entryName = $zipArchive->getNameIndex($i)) || ($statIndex = $zipArchive->statIndex($i,ZipArchive::FL_UNCHANGED))) {
            if ($entryName) {
                $newEntryName = str_replace($oldname, $newname, $entryName);
                if ($zipArchive->renameIndex($i, $newEntryName)) {
                    $renameCount++;
                }
            }

            $i++;
        }

        return $renameCount;
    }