Skip to content

Commit fb7d9ba

Browse files
committed
Adds method for determining user's real name.
1 parent a3933b4 commit fb7d9ba

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/Objects/MacUser.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class MacUser
1515
/** @var string */
1616
protected $_username;
1717
/** @var string */
18+
protected $_realName;
19+
/** @var string */
1820
protected $_dir;
1921
/** @var string */
2022
protected $_library;
@@ -110,6 +112,19 @@ public function getUserName()
110112
return $this->_username;
111113
}
112114

115+
/**
116+
* @return string|null
117+
*/
118+
public function getRealName()
119+
{
120+
if (empty($this->_realName))
121+
{
122+
$this->_realName = $this->getShellExec("/usr/bin/dscl . -read " . $this->getDir() . " RealName | sed -n 's/^ //g;2p'");
123+
}
124+
125+
return $this->_realName ?? null;
126+
}
127+
113128
/**
114129
* @param string $key The name of the password in the keychain
115130
*

0 commit comments

Comments
 (0)