Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ComposerMirror.php

function ComposerMirror::processUrl

Parameters

non-empty-string $mirrorUrl:

Return value

non-empty-string

1 call to ComposerMirror::processUrl()
Package::getUrls in vendor/composer/composer/src/Composer/Package/Package.php
@phpstan-param list<array{url: non-empty-string, preferred: bool}>|null $mirrors

File

vendor/composer/composer/src/Composer/Util/ComposerMirror.php, line 28

Class

ComposerMirror
Composer mirror utilities

Namespace

Composer\Util

Code

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 : hash('md5', $reference);
    }
    $version = strpos($version, '/') === false ? $version : hash('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;
}
RSS feed
Powered by Drupal