diff options
author | Malf Furious <m@lfurio.us> | 2018-09-12 02:53:53 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2018-09-12 02:53:53 -0400 |
commit | 11f83706e5774b417f6d8a52786e925bec88fc43 (patch) | |
tree | 74faf616800d219a32dfb2202f43313d3ec82008 /app/class/agent.class.php | |
parent | 54782f88a2987ef2d0a5a530cfd0f027c38be396 (diff) | |
download | scrott-11f83706e5774b417f6d8a52786e925bec88fc43.tar.gz scrott-11f83706e5774b417f6d8a52786e925bec88fc43.zip |
Add function agent::getAgentObj()
This is basically a constructor for agent. The actual type returned is
a contrete agent.
Diffstat (limited to 'app/class/agent.class.php')
-rw-r--r-- | app/class/agent.class.php | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/app/class/agent.class.php b/app/class/agent.class.php index 4af13d5..63a21ed 100644 --- a/app/class/agent.class.php +++ b/app/class/agent.class.php @@ -33,6 +33,23 @@ abstract class agent extends obj } /* + * Since this class is abstract, this function is provided as a + * means of constructing the appropriate agent object based on + * a GUID. + */ + public static function getAgentObj(string $guid) : agent + { + try + { + return new user($guid); + } + catch (Exception $e) + { + return new group($guid); + } + } + + /* * Check whether this agent is the owner of the given object */ public function isOwnerOf(obj $obj) : bool |