From 11f83706e5774b417f6d8a52786e925bec88fc43 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Wed, 12 Sep 2018 02:53:53 -0400 Subject: Add function agent::getAgentObj() This is basically a constructor for agent. The actual type returned is a contrete agent. --- app/class/agent.class.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 @@ -32,6 +32,23 @@ abstract class agent extends obj parent::__construct($guid); } + /* + * 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 */ -- cgit v1.2.3