1717final class BreakPointCommand extends Command
1818{
1919 public function __construct (
20- private readonly SymfonyStyle $ symfonyStyle ,
2120 private readonly OutdatedComposerFactory $ outdatedComposerFactory ,
2221 private readonly ComposerOutdatedResponseProvider $ composerOutdatedResponseProvider
2322 ) {
@@ -42,16 +41,18 @@ protected function configure(): void
4241
4342 protected function execute (InputInterface $ input , OutputInterface $ output ): int
4443 {
44+ $ symfonyStyle = new SymfonyStyle ($ input , $ output );
45+
4546 $ maxOutdatePackages = (int ) $ input ->getOption ('limit ' );
4647 $ onlyDev = (bool ) $ input ->getOption ('dev ' );
4748
48- $ this -> symfonyStyle ->writeln ('<fg=green>Analyzing "composer.json" for major outdated packages</> ' );
49+ $ symfonyStyle ->writeln ('<fg=green>Analyzing "composer.json" for major outdated packages</> ' );
4950
5051 $ responseJsonContents = $ this ->composerOutdatedResponseProvider ->provide ();
5152
5253 $ responseJson = Json::decode ($ responseJsonContents , true );
5354 if (! isset ($ responseJson [ComposerKey::INSTALLED_KEY ])) {
54- $ this -> symfonyStyle ->success ('All packages are up to date ' );
55+ $ symfonyStyle ->success ('All packages are up to date ' );
5556
5657 return self ::SUCCESS ;
5758 }
@@ -62,7 +63,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6263 $ composerJsonFilePath
6364 );
6465
65- $ this -> symfonyStyle ->title (
66+ $ symfonyStyle ->title (
6667 sprintf (
6768 'Found %d outdated package%s ' ,
6869 $ outdatedComposer ->count ($ onlyDev ),
@@ -71,25 +72,25 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7172 );
7273
7374 foreach ($ outdatedComposer ->getPackages ($ onlyDev ) as $ outdatedPackage ) {
74- $ this -> symfonyStyle ->writeln (
75+ $ symfonyStyle ->writeln (
7576 sprintf ('The "<fg=green>%s</>" package is outdated ' , $ outdatedPackage ->getName ())
7677 );
7778
78- $ this -> symfonyStyle ->writeln (sprintf (
79+ $ symfonyStyle ->writeln (sprintf (
7980 ' * Your version %s is <fg=%s>%s</> ' ,
8081 $ outdatedPackage ->getCurrentVersion (),
8182 $ outdatedPackage ->isVeryOld () ? 'red ' : 'yellow ' ,
8283 $ outdatedPackage ->getCurrentVersionAge (),
8384 ));
8485
85- $ this -> symfonyStyle ->writeln (sprintf (' * Bump to %s ' , $ outdatedPackage ->getLatestVersion ()));
86- $ this -> symfonyStyle ->newLine ();
86+ $ symfonyStyle ->writeln (sprintf (' * Bump to %s ' , $ outdatedPackage ->getLatestVersion ()));
87+ $ symfonyStyle ->newLine ();
8788 }
8889
89- $ this -> symfonyStyle ->newLine ();
90+ $ symfonyStyle ->newLine ();
9091 if ($ outdatedComposer ->count () >= $ maxOutdatePackages ) {
9192 // to much → fail
92- $ this -> symfonyStyle ->error (sprintf (
93+ $ symfonyStyle ->error (sprintf (
9394 'There %s %d outdated package%s. Update couple of them to get under %d limit ' ,
9495 $ outdatedComposer ->count () > 1 ? 'are ' : 'is ' ,
9596 $ outdatedComposer ->count (),
@@ -102,7 +103,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
102103
103104 if ($ outdatedComposer ->count () > max (1 , $ maxOutdatePackages - 5 )) {
104105 // to much → fail
105- $ this -> symfonyStyle ->warning (sprintf (
106+ $ symfonyStyle ->warning (sprintf (
106107 'There are %d outdated packages. Soon, the count will go over %d limit and this job will fail.%sUpgrade in time ' ,
107108 $ outdatedComposer ->count (),
108109 $ maxOutdatePackages ,
@@ -113,7 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
113114 }
114115
115116 // to many → fail
116- $ this -> symfonyStyle ->success (
117+ $ symfonyStyle ->success (
117118 sprintf ('Still far away from limit %d. Good job keeping your project up to date! ' , $ maxOutdatePackages )
118119 );
119120
0 commit comments