CompressedDataPacket implements ArrayAccess

This commit is contained in:
Stephen Paul Weber 2010-03-31 14:25:21 -05:00
parent 3c84dce8f9
commit 97ad2cf72d
1 changed files with 26 additions and 1 deletions

View File

@ -706,7 +706,7 @@ class OpenPGP_SecretSubkeyPacket extends OpenPGP_SecretKeyPacket {
*
* @see http://tools.ietf.org/html/rfc4880#section-5.6
*/
class OpenPGP_CompressedDataPacket extends OpenPGP_Packet {
class OpenPGP_CompressedDataPacket extends OpenPGP_Packet implements IteratorAggregate, ArrayAccess {
public $algorithm;
/* see http://tools.ietf.org/html/rfc4880#section-9.3 */
static $algorithms = array(0 => 'Uncompressed', 1 => 'ZIP', 2 => 'ZLIB', 3 => 'BZip2');
@ -733,6 +733,31 @@ class OpenPGP_CompressedDataPacket extends OpenPGP_Packet {
$this->data = $this->data->packets;
}
}
// IteratorAggregate interface
function getIterator() {
return new ArrayIterator($this->data);
}
// ArrayAccess interface
function offsetExists($offset) {
return isset($this->data[$offset]);
}
function offsetGet($offset) {
return $this->data[$offset];
}
function offsetSet($offset, $value) {
return is_null($offset) ? $this->data[] = $value : $this->data[$offset] = $value;
}
function offsetUnset($offset) {
unset($this->data[$offset]);
}
}
/**