function AuthHelper::storeAuth
Parameters
'prompt'|bool $storeAuth:
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ AuthHelper.php, line 43
Class
- AuthHelper
- @author Jordi Boggiano <j.boggiano@seld.be>
Namespace
Composer\UtilCode
public function storeAuth(string $origin, $storeAuth) : void {
$store = false;
$configSource = $this->config
->getAuthConfigSource();
if ($storeAuth === true) {
$store = $configSource;
}
elseif ($storeAuth === 'prompt') {
$answer = $this->io
->askAndValidate('Do you want to store credentials for ' . $origin . ' in ' . $configSource->getName() . ' ? [Yn] ', static function ($value) : string {
$input = strtolower(substr(trim($value), 0, 1));
if (in_array($input, [
'y',
'n',
])) {
return $input;
}
throw new \RuntimeException('Please answer (y)es or (n)o');
}, null, 'y');
if ($answer === 'y') {
$store = $configSource;
}
}
if ($store) {
$store->addConfigSetting('http-basic.' . $origin, $this->io
->getAuthentication($origin));
}
}