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
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}
*/

View File

@ -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