function Perforce::getP4variable
Return value
?string
3 calls to Perforce::getP4variable()
- Perforce::initialize in vendor/
composer/ composer/ src/ Composer/ Util/ Perforce.php - @phpstan-param RepoConfig $repoConfig
- Perforce::queryP4Password in vendor/
composer/ composer/ src/ Composer/ Util/ Perforce.php - Perforce::queryP4User in vendor/
composer/ composer/ src/ Composer/ Util/ Perforce.php
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Perforce.php, line 262
Class
- Perforce
- @author Matt Whittom <Matt.Whittom@veteransunited.com>
Namespace
Composer\UtilCode
protected function getP4variable(string $name) : ?string {
if ($this->windowsFlag) {
$command = $this->getP4Executable() . ' set';
$this->executeCommand($command);
$result = trim($this->commandResult);
$resArray = explode(PHP_EOL, $result);
foreach ($resArray as $line) {
$fields = explode('=', $line);
if (strcmp($name, $fields[0]) === 0) {
$index = strpos($fields[1], ' ');
if ($index === false) {
$value = $fields[1];
}
else {
$value = substr($fields[1], 0, $index);
}
$value = trim($value);
return $value;
}
}
return null;
}
$command = 'echo $' . $name;
$this->executeCommand($command);
$result = trim($this->commandResult);
return $result;
}