generateCompareUrl() public method

In case the from and to source urls are different, this probably means that an across fork compare url should be generated instead.
public generateCompareUrl ( string $sourceUrlFrom, Version $versionFrom, string $sourceUrlTo, Version $versionTo ) : string | false
$sourceUrlFrom string
$versionFrom Pyrech\ComposerChangelogs\Version
$sourceUrlTo string
$versionTo Pyrech\ComposerChangelogs\Version
return string | false
コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function getOutput(OperationInterface $operation, UrlGenerator $urlGenerator = null)
 {
     if (!$operation instanceof UpdateOperation) {
         throw new \LogicException('Operation should be an instance of UpdateOperation');
     }
     $output = [];
     $initialPackage = $operation->getInitialPackage();
     $targetPackage = $operation->getTargetPackage();
     $versionFrom = new Version($initialPackage->getVersion(), $initialPackage->getPrettyVersion(), method_exists($initialPackage, 'getFullPrettyVersion') ? $initialPackage->getFullPrettyVersion() : VersionParser::formatVersion($initialPackage));
     $versionTo = new Version($targetPackage->getVersion(), $targetPackage->getPrettyVersion(), method_exists($targetPackage, 'getFullPrettyVersion') ? $targetPackage->getFullPrettyVersion() : VersionParser::formatVersion($targetPackage));
     $action = 'updated';
     if (Comparator::greaterThan($versionFrom->getName(), $versionTo->getName())) {
         $action = 'downgraded';
     }
     $output[] = sprintf(' - <fg=green>%s</fg=green> %s from <fg=yellow>%s</fg=yellow> to <fg=yellow>%s</fg=yellow>', $initialPackage->getName(), $action, $versionFrom->getPretty(), $versionTo->getPretty());
     if ($urlGenerator) {
         $compareUrl = $urlGenerator->generateCompareUrl($initialPackage->getSourceUrl(), $versionFrom, $targetPackage->getSourceUrl(), $versionTo);
         if (!empty($compareUrl)) {
             $output[] = sprintf('   See changes: %s', $compareUrl);
         }
         $releaseUrl = $urlGenerator->generateReleaseUrl($this->extractSourceUrl($operation), $versionTo);
         if (!empty($releaseUrl)) {
             $output[] = sprintf('   Release notes: %s', $releaseUrl);
         }
     }
     return $output;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function getOutput(OperationInterface $operation, UrlGenerator $urlGenerator = null)
 {
     if (!$operation instanceof FakeOperation) {
         return [];
     }
     $output = [' - ' . $this->output . ', ' . $operation->getText()];
     if ($urlGenerator) {
         $output[] = '   ' . $urlGenerator->generateCompareUrl($this->sourceUrl, new Version('', '', ''), $this->sourceUrl, new Version('', '', ''));
         $output[] = '   ' . $urlGenerator->generateReleaseUrl($this->sourceUrl, new Version('', '', ''));
     }
     return $output;
 }