Skip to content

Commit 4e1e8bb

Browse files
authored
Added getUserName()
1 parent c477bbc commit 4e1e8bb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Sys.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,16 @@ public static function isRoot(): bool
5151
return false; // @codeCoverageIgnore
5252
}
5353

54+
/**
55+
* Returns current linux user who runs script
56+
* @return string|null
57+
*/
58+
public function getUserName()
59+
{
60+
$userInfo = posix_getpwuid(posix_geteuid());
61+
return $userInfo['name'] ?? null;
62+
}
63+
5464
/**
5565
* Returns a home directory of current user.
5666
*

0 commit comments

Comments
 (0)