Spiking SPL interfaces

This commit is contained in:
Chris Boden 2014-11-29 13:08:39 -05:00
parent 5e79598448
commit c1027be9a6
2 changed files with 19 additions and 3 deletions

View File

@ -1,11 +1,11 @@
<?php <?php
namespace Ratchet\RFC6455\Messaging\Protocol; namespace Ratchet\RFC6455\Messaging\Protocol;
class Message implements MessageInterface, \Countable { class Message implements MessageInterface {
/** /**
* @var \SplDoublyLinkedList * @var \SplDoublyLinkedList
*/ */
protected $_frames; private $_frames;
public function __construct() { public function __construct() {
$this->_frames = new \SplDoublyLinkedList; $this->_frames = new \SplDoublyLinkedList;
@ -18,6 +18,22 @@ class Message implements MessageInterface, \Countable {
return count($this->_frames); 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} * {@inheritdoc}
*/ */

View File

@ -1,7 +1,7 @@
<?php <?php
namespace Ratchet\RFC6455\Messaging\Protocol; namespace Ratchet\RFC6455\Messaging\Protocol;
interface MessageInterface extends DataInterface { interface MessageInterface extends DataInterface, \ArrayAccess, \Countable {
/** /**
* @param FrameInterface $fragment * @param FrameInterface $fragment
* @return MessageInterface * @return MessageInterface