Merge branch 'maint/7.0'
[ninja.git] / application / vendor / swiftmailer / classes / Swift / KeyCache / SimpleKeyCacheInputStream.php
blob87cdced81fdc0c3957b208731b241ca0974730b2
1 <?php
3 /*
4 * This file is part of SwiftMailer.
5 * (c) 2004-2009 Chris Corbyn
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
11 //@require 'Swift/KeyCache.php';
12 //@require 'Swift/KeyCacheInputStream.php';
14 /**
15 * Writes data to a KeyCache using a stream.
16 * @package Swift
17 * @subpackage KeyCache
18 * @author Chris Corbyn
20 class Swift_KeyCache_SimpleKeyCacheInputStream
21 implements Swift_KeyCache_KeyCacheInputStream
24 /** The KeyCache being written to */
25 private $_keyCache;
27 /** The nsKey of the KeyCache being written to */
28 private $_nsKey;
30 /** The itemKey of the KeyCache being written to */
31 private $_itemKey;
33 /** A stream to write through on each write() */
34 private $_writeThrough = null;
36 /**
37 * Set the KeyCache to wrap.
38 * @param Swift_KeyCache $keyCache
40 public function setKeyCache(Swift_KeyCache $keyCache)
42 $this->_keyCache = $keyCache;
45 /**
46 * Specify a stream to write through for each write().
47 * @param Swift_InputByteStream $is
49 public function setWriteThroughStream(Swift_InputByteStream $is)
51 $this->_writeThrough = $is;
54 /**
55 * Writes $bytes to the end of the stream.
56 * @param string $bytes
57 * @param Swift_InputByteStream $is, optional
59 public function write($bytes, Swift_InputByteStream $is = null)
61 $this->_keyCache->setString(
62 $this->_nsKey, $this->_itemKey, $bytes, Swift_KeyCache::MODE_APPEND
64 if (isset($is))
66 $is->write($bytes);
68 if (isset($this->_writeThrough))
70 $this->_writeThrough->write($bytes);
74 /**
75 * Not used.
77 public function commit()
81 /**
82 * Not used.
84 public function bind(Swift_InputByteStream $is)
88 /**
89 * Not used.
91 public function unbind(Swift_InputByteStream $is)
95 /**
96 * Flush the contents of the stream (empty it) and set the internal pointer
97 * to the beginning.
99 public function flushBuffers()
101 $this->_keyCache->clearKey($this->_nsKey, $this->_itemKey);
105 * Set the nsKey which will be written to.
106 * @param string $nsKey
108 public function setNsKey($nsKey)
110 $this->_nsKey = $nsKey;
114 * Set the itemKey which will be written to.
115 * @param string $itemKey
117 public function setItemKey($itemKey)
119 $this->_itemKey = $itemKey;
123 * Any implementation should be cloneable, allowing the clone to access a
124 * separate $nsKey and $itemKey.
126 public function __clone()
128 $this->_writeThrough = null;