<?php
/**
 * Zend Framework (http://framework.zend.com/)
 *
 * @link      http://github.com/zendframework/zf2 for the canonical source repository
 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
 * @license   http://framework.zend.com/license/new-bsd New BSD License
 */

namespace Zend\Authentication\Storage;

/**
 * Non-Persistent Authentication Storage
 *
 * Since HTTP Authentication happens again on each request, this will always be
 * re-populated. So there's no need to use sessions, this simple value class
 * will hold the data for rest of the current request.
 */
class NonPersistent implements StorageInterface
{
    
/**
     * Holds the actual auth data
     */
    
protected $data;

    
/**
     * Returns true if and only if storage is empty
     *
     * @return bool
     */
    
public function isEmpty()
    {
        return empty(
$this->data);
    }

    
/**
     * Returns the contents of storage
     * Behavior is undefined when storage is empty.
     *
     * @return mixed
     */
    
public function read()
    {
        return 
$this->data;
    }

    
/**
     * Writes $contents to storage
     *
     * @param  mixed $contents
     * @return void
     */
    
public function write($contents)
    {
        
$this->data $contents;
    }

    
/**
     * Clears contents from storage
     *
     * @return void
     */
    
public function clear()
    {
        
$this->data null;
    }
}