Skip to content

Commit

Permalink
Merge 18e7dbe into 3949b49
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Sep 24, 2020
2 parents 3949b49 + 18e7dbe commit 4016b38
Showing 1 changed file with 25 additions and 18 deletions.
43 changes: 25 additions & 18 deletions src/Bundle/CoverallsBundle/Config/Configurator.php
Expand Up @@ -82,7 +82,7 @@ protected function process(array $yml)
*
* @param array $options processed configuration
* @param string $rootDir path to project root directory
* @param InputInterface $input|null Input arguments
* @param InputInterface $input|null input arguments
*
* @return \PhpCoveralls\Bundle\CoverallsBundle\Config\Configuration
*/
Expand All @@ -94,23 +94,8 @@ protected function createConfiguration(array $options, $rootDir, InputInterface
$repoToken = $options['repo_token'];
$repoSecretToken = $options['repo_secret_token'];

// handle coverage clover
$coverage_clover = $options['coverage_clover'];
if ($input !== null && $input->hasOption('coverage_clover')) {
$option = $input->getOption('coverage_clover');
if (!empty($option)) {
$coverage_clover = $option;
}
}

// handle output json path
$json_path = $options['json_path'];
if ($input !== null && $input->hasOption('json_path')) {
$option = $input->getOption('json_path');
if (!empty($option)) {
$json_path = $option;
}
}
$coverage_clover = $this->getPotentiallyOverriddenOptionValue('coverage_clover', $options, $input);
$json_path = $this->getPotentiallyOverriddenOptionValue('json_path', $options, $input);

return $configuration
->setEntrypoint($options['entry_point'])
Expand Down Expand Up @@ -246,4 +231,26 @@ protected function ensureJsonPath($option, $rootDir, Path $file)

return $realpath;
}

/**
* Get option from YAML config, potentially overridden via input params.
*
* @param string $optionName option name
* @param array $options processed configuration
* @param InputInterface $input|null input arguments
*
* @return \PhpCoveralls\Bundle\CoverallsBundle\Config\Configuration
*/
private function getPotentiallyOverriddenOptionValue($optionName, array $options, InputInterface $input = null)
{
$value = $options[$optionName];
if ($input !== null && $input->hasOption($optionName)) {
$inputOverride = $input->getOption($optionName);
if (!empty($inputOverride)) {
$value = $inputOverride;
}
}

return $value;
}
}

0 comments on commit 4016b38

Please sign in to comment.