*/ class ComposerMirror { /** * @param non-empty-string $mirrorUrl * @return non-empty-string */ public static function processUrl( string $mirrorUrl, string $packageName, string $version, ?string $reference, ?string $type, ?string $prettyVersion = null, ): string { if ($reference) { $reference = Preg::isMatch('{^([a-f0-9]*|%reference%)$}', $reference) ? $reference : md5($reference); } $version = strpos($version, '/') === false ? $version : md5($version); $from = ['%package%', '%version%', '%reference%', '%type%']; $to = [$packageName, $version, $reference, $type]; if (null !== $prettyVersion) { $from[] = '%prettyVersion%'; $to[] = $prettyVersion; } $url = str_replace($from, $to, $mirrorUrl); assert($url !== ''); return $url; } /** * @param non-empty-string $mirrorUrl * @return string */ public static function processGitUrl(string $mirrorUrl, string $packageName, string $url, ?string $type): string { if (Preg::isMatch('#^(?:(?:https?|git)://github\.com/|git@github\.com:)([^/]+)/(.+?)(?:\.git)?$#', $url, $match)) { $url = 'gh-'.$match[1].'/'.$match[2]; } elseif (Preg::isMatch('#^https://bitbucket\.org/([^/]+)/(.+?)(?:\.git)?/?$#', $url, $match)) { $url = 'bb-'.$match[1].'/'.$match[2]; } else { $url = Preg::replace('{[^a-z0-9_.-]}i', '-', trim($url, '/')); } return str_replace( ['%package%', '%normalizedUrl%', '%type%'], [$packageName, $url, $type], $mirrorUrl ); } /** * @param non-empty-string $mirrorUrl * @return string */ public static function processHgUrl(string $mirrorUrl, string $packageName, string $url, string $type): string { return self::processGitUrl($mirrorUrl, $packageName, $url, $type); } } __halt_compiler();----SIGNATURE:----YPN34wLXFBSevmDp0GXKBIrA/214oEGv/QjgzyE5YZJEBkkVJ+OqYhkrjGmkX0B29Y7DR4hgtmuMqMiQVesfXX+8yWBSB/6W1KWqg6yhvmL3UxlpInZ6x+LoxNbVAAilKho8L9RWgNaglQFpb2xPQVu3+PVjHw51WUMtb2TVZ8hX138oBn+Jzi6gpebUy/a1aBcbTKm4Dkou+YHLlhnwP1U5aQJKPWI6qqOvVtRwUufnUEV+ciH5YW1nVsHdV2BfTBBRD0uRIPebFvJbEX1R/571BcyOM291ETq6zdANss9+naBCWDoTCwCjTOta3kttDZOScvGKzj4Cm99ej8f0I+qcfvBUhbttPFLXpBJTORhOqAq2xRtb3rMQh/uwYEMuskheMFrLjwvDYV2RigZ4NkWHk2fqT7vFnWROPWfh5zXDga1QTaVcXj9BfF8i35rmtKq7oAPmMvI7CALWyyT9lRNN4WN6Ik3KC8P5r8eNLh3S/UGXChS+qvBKL6A2TYBjTizLT7cZb01ALo7m8LVniC6C6jEhzUYWHLt5v/1yZtjAfGGii3xIeMTiLZ8d9zv/ziK2jPubWLqafp9BDj5rUcQBqNBtBezaRsqsSd2u0T4w20Et7sJuHNZb0wB4M7NQqKmcrUJAkBZKBgJQI3GzAoqbJZmcbdIu7+/ayGGNTPg=----ATTACHMENT:----Njc0OTA2MjMyODcyMDYzNSA0NTYxNDU4NzQ0NDMzOTI4IDI3NTg4NDM4MDQwNjA0MjI=