/** * Constructor * * @author Art <*****@*****.**> * * @param string $name Token name/ID * @param Sess|Config $cfg The instance of the currently active session. If omitted, * AbstractSession::getLastActiveSession() will be used * * @throws InvalidArgumentException if $cfg isn't an instance of Config or AbstractSession */ public function __construct($name, $cfg = null) { if ($cfg instanceof Config) { $this->tokenKey = $cfg->tokenKey; } elseif ($cfg instanceof Sess) { $this->tokenKey = $cfg->getConfig(Config::CFG_TOKEN); } elseif ($cfg === null && ($lastSession = Sess::getLastActiveSession())) { $this->tokenKey = $lastSession->getConfig(Config::CFG_TOKEN); } else { throw new InvalidArgumentException('$cfg must be an instance of ' . __NAMESPACE__ . '\\Config or ' . __NAMESPACE__ . '\\AbstractSession'); } $this->name = $name; }