public function __construct($content) { if (is_string($content) && trim($content)) { NpcFactory::fleshOut($content, $this); } else { NpcFactory::fleshOutFromData($content, $this); } }
/** * Pass the npc in and use the reference to flesh out it's data, from an identity if nothing else **/ public static function fleshOut($identity, $npc) { $npcs_data = NpcFactory::npcsData(); if (array_key_exists($identity, $npcs_data) && !empty($npcs_data[$identity])) { NpcFactory::fleshOutFromData($npcs_data[$identity], $npc); } else { throw new InvalidNpcException('No such npc [' . $identity . '] found to create!'); } }