toArray(); } elseif (is_object($options)) { $options = (array) $options; } if (null !== $options && !is_array($options)) { require_once 'Zend/Http/UserAgent/Storage/Exception.php'; throw new Zend_Http_UserAgent_Storage_Exception(sprintf( 'Expected array or object options; "%s" provided', gettype($options) )); } // add '.' to prevent the message ''Session namespace must not start with a number' $this->_namespace = '.' . (isset($options['browser_type']) ? $options['browser_type'] : self::NAMESPACE_DEFAULT); $this->_member = isset($options['member']) ? $options['member'] : self::MEMBER_DEFAULT; $this->_session = new Zend_Session_Namespace($this->_namespace); } /** * Returns the session namespace name * * @return string */ public function getNamespace() { return $this->_namespace; } /** * Returns the name of the session object member * * @return string */ public function getMember() { return $this->_member; } /** * Defined by Zend_Http_UserAgent_Storage * * @return boolean */ public function isEmpty() { return empty($this->_session->{$this->_member}); } /** * Defined by Zend_Http_UserAgent_Storage * * @return mixed */ public function read() { return $this->_session->{$this->_member}; } /** * Defined by Zend_Http_UserAgent_Storage * * @param mixed $contents * @return void */ public function write($content) { $this->_session->{$this->_member} = $content; } /** * Defined by Zend_Http_UserAgent_Storage * * @return void */ public function clear() { unset($this->_session->{$this->_member}); } }