From 60ce5e00ffa1c6a4ef02c46dbda50c8f29b896ae Mon Sep 17 00:00:00 2001
From: Chris Boden <cboden@gmail.com>
Date: Mon, 8 Feb 2016 22:21:56 -0500
Subject: [PATCH] Renamed some classes, less depth

---
 .../{Protocol => }/CloseFrameChecker.php      |  4 +--
 .../{Protocol => }/DataInterface.php          |  2 +-
 src/Messaging/{Protocol => }/Frame.php        |  2 +-
 .../{Protocol => }/FrameInterface.php         |  2 +-
 src/Messaging/{Protocol => }/Message.php      |  2 +-
 .../MessageStreamer.php => MessageBuffer.php} | 25 +++++++-----------
 .../{Protocol => }/MessageInterface.php       |  2 +-
 tests/ab/clientRunner.php                     | 26 +++++++++----------
 tests/ab/startServer.php                      | 10 +++----
 tests/unit/Messaging/Protocol/FrameTest.php   |  6 ++---
 tests/unit/Messaging/Protocol/MessageTest.php |  8 +++---
 11 files changed, 42 insertions(+), 47 deletions(-)
 rename src/Messaging/{Protocol => }/CloseFrameChecker.php (87%)
 rename src/Messaging/{Protocol => }/DataInterface.php (93%)
 rename src/Messaging/{Protocol => }/Frame.php (99%)
 rename src/Messaging/{Protocol => }/FrameInterface.php (93%)
 rename src/Messaging/{Protocol => }/Message.php (98%)
 rename src/Messaging/{Streaming/MessageStreamer.php => MessageBuffer.php} (87%)
 rename src/Messaging/{Protocol => }/MessageInterface.php (88%)

diff --git a/src/Messaging/Protocol/CloseFrameChecker.php b/src/Messaging/CloseFrameChecker.php
similarity index 87%
rename from src/Messaging/Protocol/CloseFrameChecker.php
rename to src/Messaging/CloseFrameChecker.php
index 7556b97..3d800e5 100644
--- a/src/Messaging/Protocol/CloseFrameChecker.php
+++ b/src/Messaging/CloseFrameChecker.php
@@ -1,8 +1,8 @@
 <?php
-namespace Ratchet\RFC6455\Messaging\Protocol;
+namespace Ratchet\RFC6455\Messaging;
 
 class CloseFrameChecker {
-    private $validCloseFrames = [];
+    private $validCloseCodes = [];
 
     public function __construct() {
         $this->validCloseCodes = [
diff --git a/src/Messaging/Protocol/DataInterface.php b/src/Messaging/DataInterface.php
similarity index 93%
rename from src/Messaging/Protocol/DataInterface.php
rename to src/Messaging/DataInterface.php
index 2b0c675..18aa2e3 100644
--- a/src/Messaging/Protocol/DataInterface.php
+++ b/src/Messaging/DataInterface.php
@@ -1,5 +1,5 @@
 <?php
-namespace Ratchet\RFC6455\Messaging\Protocol;
+namespace Ratchet\RFC6455\Messaging;
 
 interface DataInterface {
     /**
diff --git a/src/Messaging/Protocol/Frame.php b/src/Messaging/Frame.php
similarity index 99%
rename from src/Messaging/Protocol/Frame.php
rename to src/Messaging/Frame.php
index aaf8e0e..ead5544 100644
--- a/src/Messaging/Protocol/Frame.php
+++ b/src/Messaging/Frame.php
@@ -1,5 +1,5 @@
 <?php
-namespace Ratchet\RFC6455\Messaging\Protocol;
+namespace Ratchet\RFC6455\Messaging;
 
 class Frame implements FrameInterface {
     const OP_CONTINUE =  0;
diff --git a/src/Messaging/Protocol/FrameInterface.php b/src/Messaging/FrameInterface.php
similarity index 93%
rename from src/Messaging/Protocol/FrameInterface.php
rename to src/Messaging/FrameInterface.php
index ca52a92..dc24091 100644
--- a/src/Messaging/Protocol/FrameInterface.php
+++ b/src/Messaging/FrameInterface.php
@@ -1,5 +1,5 @@
 <?php
-namespace Ratchet\RFC6455\Messaging\Protocol;
+namespace Ratchet\RFC6455\Messaging;
 
 interface FrameInterface extends DataInterface {
     /**
diff --git a/src/Messaging/Protocol/Message.php b/src/Messaging/Message.php
similarity index 98%
rename from src/Messaging/Protocol/Message.php
rename to src/Messaging/Message.php
index 6f35344..4f3b014 100644
--- a/src/Messaging/Protocol/Message.php
+++ b/src/Messaging/Message.php
@@ -1,5 +1,5 @@
 <?php
-namespace Ratchet\RFC6455\Messaging\Protocol;
+namespace Ratchet\RFC6455\Messaging;
 
 class Message implements \IteratorAggregate, MessageInterface {
     /**
diff --git a/src/Messaging/Streaming/MessageStreamer.php b/src/Messaging/MessageBuffer.php
similarity index 87%
rename from src/Messaging/Streaming/MessageStreamer.php
rename to src/Messaging/MessageBuffer.php
index 3b999d9..fc304b1 100644
--- a/src/Messaging/Streaming/MessageStreamer.php
+++ b/src/Messaging/MessageBuffer.php
@@ -1,14 +1,9 @@
 <?php
-namespace Ratchet\RFC6455\Messaging\Streaming;
-use Ratchet\RFC6455\Messaging\Protocol\CloseFrameChecker;
-use Ratchet\RFC6455\Messaging\Protocol\MessageInterface;
-use Ratchet\RFC6455\Messaging\Protocol\FrameInterface;
-use Ratchet\RFC6455\Messaging\Protocol\Message;
-use Ratchet\RFC6455\Messaging\Protocol\Frame;
+namespace Ratchet\RFC6455\Messaging;
 
-class MessageStreamer {
+class MessageBuffer {
     /**
-     * @var \Ratchet\RFC6455\Messaging\Protocol\CloseFrameChecker
+     * @var \Ratchet\RFC6455\Messaging\CloseFrameChecker
      */
     private $closeFrameChecker;
 
@@ -18,12 +13,12 @@ class MessageStreamer {
     private $exceptionFactory;
 
     /**
-     * @var \Ratchet\RFC6455\Messaging\Protocol\Message
+     * @var \Ratchet\RFC6455\Messaging\Message
      */
     private $messageBuffer;
 
     /**
-     * @var \Ratchet\RFC6455\Messaging\Protocol\Frame
+     * @var \Ratchet\RFC6455\Messaging\Frame
      */
     private $frameBuffer;
 
@@ -113,8 +108,8 @@ class MessageStreamer {
 
     /**
      * Check a frame to be added to the current message buffer
-     * @param \Ratchet\RFC6455\Messaging\Protocol\FrameInterface|FrameInterface $frame
-     * @return \Ratchet\RFC6455\Messaging\Protocol\FrameInterface|FrameInterface
+     * @param \Ratchet\RFC6455\Messaging\FrameInterface|FrameInterface $frame
+     * @return \Ratchet\RFC6455\Messaging\FrameInterface|FrameInterface
      */
     public function frameCheck(FrameInterface $frame) {
         if (false !== $frame->getRsv1() ||
@@ -188,7 +183,7 @@ class MessageStreamer {
 
     /**
      * Determine if a message is valid
-     * @param \Ratchet\RFC6455\Messaging\Protocol\MessageInterface
+     * @param \Ratchet\RFC6455\Messaging\MessageInterface
      * @return bool|int true if valid - false if incomplete - int of recommended close code
      */
     public function checkMessage(MessageInterface $message) {
@@ -210,7 +205,7 @@ class MessageStreamer {
     }
 
     /**
-     * @return \Ratchet\RFC6455\Messaging\Protocol\MessageInterface
+     * @return \Ratchet\RFC6455\Messaging\MessageInterface
      */
     public function newMessage() {
         return new Message;
@@ -220,7 +215,7 @@ class MessageStreamer {
      * @param string|null $payload
      * @param bool|null   $final
      * @param int|null    $opcode
-     * @return \Ratchet\RFC6455\Messaging\Protocol\FrameInterface
+     * @return \Ratchet\RFC6455\Messaging\FrameInterface
      */
     public function newFrame($payload = null, $final = null, $opcode = null) {
         return new Frame($payload, $final, $opcode, $this->exceptionFactory);
diff --git a/src/Messaging/Protocol/MessageInterface.php b/src/Messaging/MessageInterface.php
similarity index 88%
rename from src/Messaging/Protocol/MessageInterface.php
rename to src/Messaging/MessageInterface.php
index f153686..fd7212e 100644
--- a/src/Messaging/Protocol/MessageInterface.php
+++ b/src/Messaging/MessageInterface.php
@@ -1,5 +1,5 @@
 <?php
-namespace Ratchet\RFC6455\Messaging\Protocol;
+namespace Ratchet\RFC6455\Messaging;
 
 interface MessageInterface extends DataInterface, \Traversable, \Countable {
     /**
diff --git a/tests/ab/clientRunner.php b/tests/ab/clientRunner.php
index bb58832..559a1aa 100644
--- a/tests/ab/clientRunner.php
+++ b/tests/ab/clientRunner.php
@@ -1,7 +1,7 @@
 <?php
 use GuzzleHttp\Psr7\Uri;
 use React\Promise\Deferred;
-use Ratchet\RFC6455\Messaging\Protocol\Frame;
+use Ratchet\RFC6455\Messaging\Frame;
 
 require __DIR__ . '/../bootstrap.php';
 
@@ -18,16 +18,16 @@ $factory = new \React\SocketClient\Connector($loop, $dnsResolver);
 
 function echoStreamerFactory($conn)
 {
-    return new \Ratchet\RFC6455\Messaging\Streaming\MessageStreamer(
-        new \Ratchet\RFC6455\Messaging\Protocol\CloseFrameChecker,
-        function (\Ratchet\RFC6455\Messaging\Protocol\MessageInterface $msg) use ($conn) {
+    return new \Ratchet\RFC6455\Messaging\MessageBuffer(
+        new \Ratchet\RFC6455\Messaging\CloseFrameChecker,
+        function (\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($conn) {
             /** @var Frame $frame */
             foreach ($msg as $frame) {
                 $frame->maskPayload();
             }
             $conn->write($msg->getContents());
         },
-        function (\Ratchet\RFC6455\Messaging\Protocol\FrameInterface $frame) use ($conn) {
+        function (\Ratchet\RFC6455\Messaging\FrameInterface $frame) use ($conn) {
             switch ($frame->getOpcode()) {
                 case Frame::OP_PING:
                     return $conn->write((new Frame($frame->getPayload(), true, Frame::OP_PONG))->maskPayload()->getContents());
@@ -54,7 +54,7 @@ function getTestCases() {
         $rawResponse = "";
         $response = null;
 
-        /** @var \Ratchet\RFC6455\Messaging\Streaming\MessageStreamer $ms */
+        /** @var \Ratchet\RFC6455\Messaging\Streaming\MessageBuffer $ms */
         $ms = null;
 
         $stream->on('data', function ($data) use ($stream, &$rawResponse, &$response, &$ms, $cn, $deferred, &$context, $cnRequest) {
@@ -70,9 +70,9 @@ function getTestCases() {
                         $stream->end();
                         $deferred->reject();
                     } else {
-                        $ms = new \Ratchet\RFC6455\Messaging\Streaming\MessageStreamer(
-                            new \Ratchet\RFC6455\Messaging\Protocol\CloseFrameChecker,
-                            function (\Ratchet\RFC6455\Messaging\Protocol\MessageInterface $msg) use ($deferred, $stream) {
+                        $ms = new \Ratchet\RFC6455\Messaging\MessageBuffer(
+                            new \Ratchet\RFC6455\Messaging\CloseFrameChecker,
+                            function (\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($deferred, $stream) {
                                 $deferred->resolve($msg->getPayload());
                                 $stream->close();
                             },
@@ -161,7 +161,7 @@ function createReport() {
         $rawResponse = "";
         $response = null;
 
-        /** @var \Ratchet\RFC6455\Messaging\Streaming\MessageStreamer $ms */
+        /** @var \Ratchet\RFC6455\Messaging\Streaming\MessageBuffer $ms */
         $ms = null;
 
         $stream->on('data', function ($data) use ($stream, &$rawResponse, &$response, &$ms, $cn, $deferred, &$context, $cnRequest) {
@@ -177,9 +177,9 @@ function createReport() {
                         $stream->end();
                         $deferred->reject();
                     } else {
-                        $ms = new \Ratchet\RFC6455\Messaging\Streaming\MessageStreamer(
-                            new \Ratchet\RFC6455\Messaging\Protocol\CloseFrameChecker,
-                            function (\Ratchet\RFC6455\Messaging\Protocol\MessageInterface $msg) use ($deferred, $stream) {
+                        $ms = new \Ratchet\RFC6455\Messaging\MessageBuffer(
+                            new \Ratchet\RFC6455\Messaging\CloseFrameChecker,
+                            function (\Ratchet\RFC6455\Messaging\MessageInterface $msg) use ($deferred, $stream) {
                                 $deferred->resolve($msg->getPayload());
                                 $stream->close();
                             },
diff --git a/tests/ab/startServer.php b/tests/ab/startServer.php
index 778318d..846b0be 100644
--- a/tests/ab/startServer.php
+++ b/tests/ab/startServer.php
@@ -1,7 +1,7 @@
 <?php
-use Ratchet\RFC6455\Messaging\Protocol\MessageInterface;
-use Ratchet\RFC6455\Messaging\Protocol\FrameInterface;
-use Ratchet\RFC6455\Messaging\Protocol\Frame;
+use Ratchet\RFC6455\Messaging\MessageInterface;
+use Ratchet\RFC6455\Messaging\FrameInterface;
+use Ratchet\RFC6455\Messaging\Frame;
 
 require_once __DIR__ . "/../bootstrap.php";
 
@@ -10,7 +10,7 @@ $loop   = \React\EventLoop\Factory::create();
 $socket = new \React\Socket\Server($loop);
 $server = new \React\Http\Server($socket);
 
-$closeFrameChecker = new \Ratchet\RFC6455\Messaging\Protocol\CloseFrameChecker;
+$closeFrameChecker = new \Ratchet\RFC6455\Messaging\CloseFrameChecker;
 $negotiator = new \Ratchet\RFC6455\Handshake\Negotiator;
 
 $uException = new \UnderflowException;
@@ -33,7 +33,7 @@ $server->on('request', function (\React\Http\Request $request, \React\Http\Respo
         return;
     }
 
-    $parser = new \Ratchet\RFC6455\Messaging\Streaming\MessageStreamer($closeFrameChecker, function(MessageInterface $message) use ($response) {
+    $parser = new \Ratchet\RFC6455\Messaging\MessageBuffer($closeFrameChecker, function(MessageInterface $message) use ($response) {
         $response->write($message->getContents());
     }, function(FrameInterface $frame) use ($response, &$parser) {
         switch ($frame->getOpCode()) {
diff --git a/tests/unit/Messaging/Protocol/FrameTest.php b/tests/unit/Messaging/Protocol/FrameTest.php
index e0a4f61..2aa2e1f 100644
--- a/tests/unit/Messaging/Protocol/FrameTest.php
+++ b/tests/unit/Messaging/Protocol/FrameTest.php
@@ -1,9 +1,9 @@
 <?php
-namespace Ratchet\RFC6455\Test\Unit\Messaging\Protocol;
-use Ratchet\RFC6455\Messaging\Protocol\Frame;
+namespace Ratchet\RFC6455\Test\Unit\Messaging;
+use Ratchet\RFC6455\Messaging\Frame;
 
 /**
- * @covers Ratchet\RFC6455\Messaging\Protocol\Frame
+ * @covers Ratchet\RFC6455\MessagingFrame
  * @todo getMaskingKey, getPayloadStartingByte don't have tests yet
  * @todo Could use some clean up in general, I had to rush to fix a bug for a deadline, sorry.
  */
diff --git a/tests/unit/Messaging/Protocol/MessageTest.php b/tests/unit/Messaging/Protocol/MessageTest.php
index e41730f..1f7eab5 100644
--- a/tests/unit/Messaging/Protocol/MessageTest.php
+++ b/tests/unit/Messaging/Protocol/MessageTest.php
@@ -1,10 +1,10 @@
 <?php
-namespace Ratchet\RFC6455\Test\Unit\Messaging\Protocol;
-use Ratchet\RFC6455\Messaging\Protocol\Frame;
-use Ratchet\RFC6455\Messaging\Protocol\Message;
+namespace Ratchet\RFC6455\Test\Unit\Messaging;
+use Ratchet\RFC6455\Messaging\Frame;
+use Ratchet\RFC6455\Messaging\Message;
 
 /**
- * @covers Ratchet\RFC6455\Messaging\Protocol\Message
+ * @covers Ratchet\RFC6455\Messaging\Message
  */
 class MessageTest extends \PHPUnit_Framework_TestCase {
     /** @var Message */