Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't load composer.json file twice #116

Merged
merged 1 commit into from Aug 8, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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