66use Composer \DependencyResolver \Operation \OperationInterface ;
77use Composer \DependencyResolver \Operation \UninstallOperation ;
88use Composer \DependencyResolver \Operation \UpdateOperation ;
9- use Composer \Package \PackageInterface ;
109use IonBazan \ComposerDiff \Diff \DiffEntry ;
1110use IonBazan \ComposerDiff \Url \GeneratorContainer ;
1211use Symfony \Component \Console \Output \OutputInterface ;
@@ -37,11 +36,11 @@ public function getUrl(DiffEntry $entry)
3736 $ operation = $ entry ->getOperation ();
3837
3938 if ($ operation instanceof UpdateOperation) {
40- return $ this ->getCompareUrl ($ operation ->getInitialPackage (), $ operation ->getTargetPackage ());
39+ return $ this ->generators -> getCompareUrl ($ operation ->getInitialPackage (), $ operation ->getTargetPackage ());
4140 }
4241
4342 if ($ operation instanceof InstallOperation || $ operation instanceof UninstallOperation) {
44- return $ this ->getReleaseUrl ($ operation ->getPackage ());
43+ return $ this ->generators -> getReleaseUrl ($ operation ->getPackage ());
4544 }
4645
4746 return null ;
@@ -64,40 +63,35 @@ public function getProjectUrl(OperationInterface $operation)
6463 return null ;
6564 }
6665
67- $ generator = $ this ->generators ->get ($ package );
68-
69- if (!$ generator ) {
70- return null ;
71- }
72-
73- return $ generator ->getProjectUrl ($ package );
66+ return $ this ->generators ->getProjectUrl ($ package );
7467 }
7568
7669 /**
77- * @return string|null
70+ * @return string
7871 */
79- private function getCompareUrl ( PackageInterface $ basePackage , PackageInterface $ targetPackage )
72+ protected function getDecoratedPackageName ( DiffEntry $ entry )
8073 {
81- $ generator = $ this -> generators -> get ( $ targetPackage );
74+ $ package = $ entry -> getPackage ( );
8275
83- if (! $ generator ) {
84- return null ;
76+ if (null === $ package ) {
77+ return '' ;
8578 }
8679
87- return $ generator -> getCompareUrl ( $ basePackage , $ targetPackage );
80+ return $ this -> terminalLink ( $ this -> getProjectUrl ( $ entry -> getOperation ()) , $ package -> getName () );
8881 }
8982
9083 /**
91- * @return string|null
84+ * @param string|null $url
85+ * @param string $title
86+ *
87+ * @return string
9288 */
93- private function getReleaseUrl ( PackageInterface $ package )
89+ private function terminalLink ( $ url , $ title )
9490 {
95- $ generator = $ this ->generators ->get ($ package );
96-
97- if (!$ generator ) {
98- return null ;
91+ if (null === $ url ) {
92+ return $ title ;
9993 }
10094
101- return $ generator -> getReleaseUrl ( $ package ) ;
95+ return method_exists ( ' Symfony\Component\Console\Formatter\OutputFormatterStyle ' , ' setHref ' ) ? sprintf ( ' <href=%s>%s</> ' , $ url , $ title ) : $ title ;
10296 }
10397}
0 commit comments