1
0
Fork 0

Minor code reorg to reduce duplication

pull/1658/head
Miklós Márton 2013-03-04 20:35:29 +01:00
parent 0d81ab7f46
commit 9110c6413e
1 changed files with 9 additions and 6 deletions

View File

@ -248,20 +248,23 @@ EOT
return $this->configSource->addConfigSetting('github-oauth.'.$matches[1], $values[0]);
}
$booleanValidator = function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); };
$booleanNormalizer = function ($val) { return $val !== 'false' && (bool) $val; };
// handle config values
$uniqueConfigValues = array(
'process-timeout' => array('is_numeric', 'intval'),
'use-include-path' => array(
function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); },
function ($val) { return $val !== 'false' && (bool) $val; }
$booleanValidator,
$booleanNormalizer
),
'prefer-source' => array(
function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); },
function ($val) { return $val !== 'false' && (bool) $val; }
$booleanValidator,
$booleanNormalizer
),
'notify-on-install' => array(
function ($val) { return in_array($val, array('true', 'false', '1', '0'), true); },
function ($val) { return $val !== 'false' && (bool) $val; }
$booleanValidator,
$booleanNormalizer
),
'vendor-dir' => array('is_string', function ($val) { return $val; }),
'bin-dir' => array('is_string', function ($val) { return $val; }),