diff --git a/src/Composer/DependencyTreeRetriever.php b/src/Composer/DependencyTreeRetriever.php index 58dae90..7ca8880 100644 --- a/src/Composer/DependencyTreeRetriever.php +++ b/src/Composer/DependencyTreeRetriever.php @@ -7,8 +7,14 @@ class DependencyTreeRetriever { + private static $output; + public function getDependencyTree(): string { + if (!is_null(self::$output)) { + return self::$output; + } + $process = new Process(['composer', 'show', '-t', '-f', 'json']); $process->run(); @@ -16,6 +22,8 @@ public function getDependencyTree(): string throw new ProcessFailedException($process); } - return $process->getOutput(); + self::$output = $process->getOutput(); + + return self::$output; } } diff --git a/src/Composer/UsedLicensesRetriever.php b/src/Composer/UsedLicensesRetriever.php index 12144db..3742b88 100644 --- a/src/Composer/UsedLicensesRetriever.php +++ b/src/Composer/UsedLicensesRetriever.php @@ -7,8 +7,14 @@ class UsedLicensesRetriever { + private static $output; + public function getComposerLicenses(): string { + if (!is_null(self::$output)) { + return self::$output; + } + $process = new Process(['composer', 'license', '-f', 'json']); $process->run(); @@ -16,6 +22,8 @@ public function getComposerLicenses(): string throw new ProcessFailedException($process); } - return $process->getOutput(); + self::$output = $process->getOutput(); + + return self::$output; } }