/** * {@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; }
/** * {@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; }