function Platform::getUserDirectory
Return value
string The formal user home as detected from environment parameters
Throws
\RuntimeException If the user home could not reliably be determined
1 call to Platform::getUserDirectory()
- Platform::expandPath in vendor/
composer/ composer/ src/ Composer/ Util/ Platform.php - Parses tildes and environment variables in paths.
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ Platform.php, line 133
Class
- Platform
- Platform helper for uniform platform-specific tests.
Namespace
Composer\UtilCode
public static function getUserDirectory() : string {
if (false !== ($home = self::getEnv('HOME'))) {
return $home;
}
if (self::isWindows() && false !== ($home = self::getEnv('USERPROFILE'))) {
return $home;
}
if (\function_exists('posix_getuid') && \function_exists('posix_getpwuid')) {
$info = posix_getpwuid(posix_getuid());
if (is_array($info)) {
return $info['dir'];
}
}
throw new \RuntimeException('Could not determine user directory');
}