diff --git a/src/Messaging/Protocol/Message.php b/src/Messaging/Protocol/Message.php index 17e8537..96a6b4a 100644 --- a/src/Messaging/Protocol/Message.php +++ b/src/Messaging/Protocol/Message.php @@ -1,11 +1,11 @@ <?php namespace Ratchet\RFC6455\Messaging\Protocol; -class Message implements MessageInterface, \Countable { +class Message implements MessageInterface { /** * @var \SplDoublyLinkedList */ - protected $_frames; + private $_frames; public function __construct() { $this->_frames = new \SplDoublyLinkedList; @@ -18,6 +18,22 @@ class Message implements MessageInterface, \Countable { return count($this->_frames); } + public function offsetExists($index) { + return $this->_frames->offsetExists($index); + } + + public function offsetGet($index) { + return $this->_frames->offsetGet($index); + } + + public function offsetSet($index, $newval) { + throw new \DomainException('Frame access in messages is read-only'); + } + + public function offsetUnset($index) { + throw new \DomainException('Frame access in messages is read-only'); + } + /** * {@inheritdoc} */ diff --git a/src/Messaging/Protocol/MessageInterface.php b/src/Messaging/Protocol/MessageInterface.php index 7cefa0a..a103145 100644 --- a/src/Messaging/Protocol/MessageInterface.php +++ b/src/Messaging/Protocol/MessageInterface.php @@ -1,7 +1,7 @@ <?php namespace Ratchet\RFC6455\Messaging\Protocol; -interface MessageInterface extends DataInterface { +interface MessageInterface extends DataInterface, \ArrayAccess, \Countable { /** * @param FrameInterface $fragment * @return MessageInterface