@@ -13,16 +13,16 @@ class MarkdownListFormatter extends MarkdownFormatter
1313 /**
1414 * {@inheritdoc}
1515 */
16- public function render (DiffEntries $ prodEntries , DiffEntries $ devEntries , $ withUrls )
16+ public function render (DiffEntries $ prodEntries , DiffEntries $ devEntries , $ withUrls, $ withLicenses )
1717 {
18- $ this ->renderSingle ($ prodEntries , 'Prod Packages ' , $ withUrls );
19- $ this ->renderSingle ($ devEntries , 'Dev Packages ' , $ withUrls );
18+ $ this ->renderSingle ($ prodEntries , 'Prod Packages ' , $ withUrls, $ withLicenses );
19+ $ this ->renderSingle ($ devEntries , 'Dev Packages ' , $ withUrls, $ withLicenses );
2020 }
2121
2222 /**
2323 * {@inheritdoc}
2424 */
25- public function renderSingle (DiffEntries $ entries , $ title , $ withUrls )
25+ public function renderSingle (DiffEntries $ entries , $ title , $ withUrls, $ withLicenses )
2626 {
2727 if (!\count ($ entries )) {
2828 return ;
@@ -33,32 +33,36 @@ public function renderSingle(DiffEntries $entries, $title, $withUrls)
3333 $ this ->output ->writeln ('' );
3434
3535 foreach ($ entries as $ entry ) {
36- $ this ->output ->writeln ($ this ->getRow ($ entry , $ withUrls ));
36+ $ this ->output ->writeln ($ this ->getRow ($ entry , $ withUrls, $ withLicenses ));
3737 }
3838
3939 $ this ->output ->writeln ('' );
4040 }
4141
4242 /**
4343 * @param bool $withUrls
44+ * @param bool $withLicenses
4445 *
4546 * @return string
4647 */
47- private function getRow (DiffEntry $ entry , $ withUrls )
48+ private function getRow (DiffEntry $ entry , $ withUrls, $ withLicenses )
4849 {
4950 $ url = $ withUrls ? $ this ->formatUrl ($ this ->getUrl ($ entry ), 'Compare ' ) : null ;
50- $ url = (null !== $ url ) ? ' ' .$ url : '' ;
51+ $ url = (null !== $ url && '' !== $ url ) ? ' ' .$ url : '' ;
52+ $ licenses = $ withLicenses ? $ this ->getLicenses ($ entry ) : null ;
53+ $ licenses = (null !== $ licenses ) ? ' (License: ' .$ licenses .') ' : '' ;
5154 $ operation = $ entry ->getOperation ();
5255
5356 if ($ operation instanceof InstallOperation) {
5457 $ packageName = $ operation ->getPackage ()->getName ();
5558 $ packageUrl = $ withUrls ? $ this ->formatUrl ($ this ->getProjectUrl ($ operation ), $ packageName ) : $ packageName ;
5659
5760 return sprintf (
58- ' - Install <fg=green>%s</> (<fg=yellow>%s</>)%s ' ,
61+ ' - Install <fg=green>%s</> (<fg=yellow>%s</>)%s%s ' ,
5962 $ packageUrl ?: $ packageName ,
6063 $ operation ->getPackage ()->getFullPrettyVersion (),
61- $ url
64+ $ url ,
65+ $ licenses
6266 );
6367 }
6468
@@ -67,12 +71,13 @@ private function getRow(DiffEntry $entry, $withUrls)
6771 $ projectUrl = $ withUrls ? $ this ->formatUrl ($ this ->getProjectUrl ($ operation ), $ packageName ) : $ packageName ;
6872
6973 return sprintf (
70- ' - %s <fg=green>%s</> (<fg=yellow>%s</> => <fg=yellow>%s</>)%s ' ,
74+ ' - %s <fg=green>%s</> (<fg=yellow>%s</> => <fg=yellow>%s</>)%s%s ' ,
7175 ucfirst ($ entry ->getType ()),
7276 $ projectUrl ?: $ packageName ,
7377 $ operation ->getInitialPackage ()->getFullPrettyVersion (),
7478 $ operation ->getTargetPackage ()->getFullPrettyVersion (),
75- $ url
79+ $ url ,
80+ $ licenses
7681 );
7782 }
7883
@@ -81,10 +86,11 @@ private function getRow(DiffEntry $entry, $withUrls)
8186 $ packageUrl = $ withUrls ? $ this ->formatUrl ($ this ->getProjectUrl ($ operation ), $ packageName ) : $ packageName ;
8287
8388 return sprintf (
84- ' - Uninstall <fg=green>%s</> (<fg=yellow>%s</>)%s ' ,
89+ ' - Uninstall <fg=green>%s</> (<fg=yellow>%s</>)%s%s ' ,
8590 $ packageUrl ?: $ packageName ,
8691 $ operation ->getPackage ()->getFullPrettyVersion (),
87- $ url
92+ $ url ,
93+ $ licenses
8894 );
8995 }
9096
0 commit comments