File indexing completed on 2024-06-16 05:25:46

0001 <?php
0002 /**
0003  * Zend Framework
0004  *
0005  * LICENSE
0006  *
0007  * This source file is subject to the new BSD license that is bundled
0008  * with this package in the file LICENSE.txt.
0009  * It is also available through the world-wide-web at this URL:
0010  * http://framework.zend.com/license/new-bsd
0011  * If you did not receive a copy of the license and are unable to
0012  * obtain it through the world-wide-web, please send an email
0013  * to license@zend.com so we can send you a copy immediately.
0014  *
0015  * @category   Zend
0016  * @package    Zend_Auth
0017  * @subpackage Storage
0018  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0019  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0020  * @version    $Id$
0021  */
0022 
0023 
0024 /**
0025  * @see Zend_Auth_Storage_Interface
0026  */
0027 // require_once 'Zend/Auth/Storage/Interface.php';
0028 
0029 
0030 /**
0031  * Non-Persistent Auth Storage
0032  *
0033  * Since HTTP Authentication happens again on each request, this will always be
0034  * re-populated. So there's no need to use sessions, this simple value class
0035  * will hold the data for rest of the current request.
0036  *
0037  * @category   Zend
0038  * @package    Zend_Auth
0039  * @subpackage Storage
0040  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0041  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0042  */
0043 class Zend_Auth_Storage_NonPersistent implements Zend_Auth_Storage_Interface
0044 {
0045     /**
0046      * Holds the actual auth data
0047      */
0048     protected $_data;
0049 
0050     /**
0051      * Returns true if and only if storage is empty
0052      *
0053      * @throws Zend_Auth_Storage_Exception If it is impossible to determine whether storage is empty
0054      * @return boolean
0055      */
0056     public function isEmpty()
0057     {
0058         return empty($this->_data);
0059     }
0060 
0061     /**
0062      * Returns the contents of storage
0063      * Behavior is undefined when storage is empty.
0064      *
0065      * @throws Zend_Auth_Storage_Exception If reading contents from storage is impossible
0066      * @return mixed
0067      */
0068     public function read()
0069     {
0070         return $this->_data;
0071     }
0072 
0073     /**
0074      * Writes $contents to storage
0075      *
0076      * @param  mixed $contents
0077      * @throws Zend_Auth_Storage_Exception If writing $contents to storage is impossible
0078      * @return void
0079      */
0080     public function write($contents)
0081     {
0082         $this->_data = $contents;
0083     }
0084 
0085     /**
0086      * Clears contents from storage
0087      *
0088      * @throws Zend_Auth_Storage_Exception If clearing contents from storage is impossible
0089      * @return void
0090      */
0091     public function clear()
0092     {
0093         $this->_data = null;
0094     }
0095 }