Skip to content

Commit

Permalink
Don't load composer.json file twice
Browse files Browse the repository at this point in the history
  • Loading branch information
pierredup committed Aug 1, 2019
1 parent a14b752 commit 4546b8b
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions src/ComposerRequireChecker/Cli/CheckCommand.php
Expand Up @@ -61,8 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
if (false === $composerJson) {
throw new \InvalidArgumentException('file not found: [' . $input->getArgument('composer-json') . ']');
}
$this->checkJsonFile($composerJson);
$composerData = (new JsonLoader($composerJson))->getData();
$composerData = $this->getComposerData($composerJson);

$options = $this->getCheckOptions($input);

Expand Down Expand Up @@ -142,12 +141,11 @@ private function getCheckOptions(InputInterface $input): Options
* @param string $jsonFile
* @throws \ComposerRequireChecker\Exception\InvalidJsonException
* @throws \ComposerRequireChecker\Exception\NotReadableException
* @internal param string $composerJson the path to composer.json
*/
private function checkJsonFile(string $jsonFile)
private function getComposerData(string $jsonFile): array
{
// JsonLoader throws an exception if it cannot load the file
new JsonLoader($jsonFile);
return (new JsonLoader($jsonFile))->getData();
}

/**
Expand Down

0 comments on commit 4546b8b

Please sign in to comment.