Passed
Push — master ( 6ac744...48d05f )
by Mohammad
07:18
created
src/Traits/WebSocketMessagesManager.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,6 @@
 block discarded – undo
11 11
 
12 12
 use Shamaseen\Laravel\Ratchet\Exceptions\WebSocketException;
13 13
 use Ratchet\ConnectionInterface;
14
-use Shamaseen\Laravel\Ratchet\Objects\Rooms\Room;
15 14
 
16 15
 /**
17 16
  * Trait WebSocketMessagesManager
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -46,11 +46,13 @@
 block discarded – undo
46 46
      */
47 47
     function sendToWebSocketUser(ConnectionInterface $conn,$data)
48 48
     {
49
-        if(!is_array($data))
50
-            $data = ['msg'=>$data];
49
+        if(!is_array($data)) {
50
+                    $data = ['msg'=>$data];
51
+        }
51 52
 
52
-        if(isset($this->route) && $this->route->auth && !array_key_exists('sender',$data))
53
-            $data['sender'] = $this->getSenderData();
53
+        if(isset($this->route) && $this->route->auth && !array_key_exists('sender',$data)) {
54
+                    $data['sender'] = $this->getSenderData();
55
+        }
54 56
 
55 57
         $conn->send(json_encode($data));
56 58
     }
Please login to merge, or discard this patch.
src/Objects/Rooms/Room.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,8 +44,9 @@
 block discarded – undo
44 44
 
45 45
     function hasMember($client)
46 46
     {
47
-        if(array_key_exists($client->id,$this->members))
48
-            return true;
47
+        if(array_key_exists($client->id,$this->members)) {
48
+                    return true;
49
+        }
49 50
 
50 51
         return false;
51 52
     }
Please login to merge, or discard this patch.
src/Traits/RoomUtility.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -78,8 +78,9 @@
 block discarded – undo
78 78
         /** @var Room $room */
79 79
         $room = $this->rooms[$room_id];
80 80
         $client = $this->clients[$this->userAuthSocketMapper[\Auth::id()]];
81
-        if(!$this->hasMember($client))
82
-            $this->error($this->request,$this->conn,'You can\'t send a message to room which you are not in !');
81
+        if(!$this->hasMember($client)) {
82
+                    $this->error($this->request,$this->conn,'You can\'t send a message to room which you are not in !');
83
+        }
83 84
 
84 85
         foreach ($room->members as $member)
85 86
         {
Please login to merge, or discard this patch.
src/Receiver.php 1 patch
Braces   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -79,10 +79,11 @@  discard block
 block discarded – undo
79 79
             \Session::start();
80 80
 
81 81
             $route = $this->routes[$msg->route];
82
-            if($route->auth && !\Auth::check())
83
-                $this->error($msg,$from,'Unauthenticated.');
84
-            else
85
-                $this->userAuthSocketMapper[\Auth::id()] = $from->resourceId;
82
+            if($route->auth && !\Auth::check()) {
83
+                            $this->error($msg,$from,'Unauthenticated.');
84
+            } else {
85
+                            $this->userAuthSocketMapper[\Auth::id()] = $from->resourceId;
86
+            }
86 87
 
87 88
             $class = $route->controller;
88 89
             $method = $route->method;
@@ -101,12 +102,10 @@  discard block
 block discarded – undo
101 102
             }
102 103
 
103 104
             $controller->$method();
104
-        }
105
-        catch (WebSocketException $exception)
105
+        } catch (WebSocketException $exception)
106 106
         {
107 107
 
108
-        }
109
-        catch(ValidationException $exception)
108
+        } catch(ValidationException $exception)
110 109
         {
111 110
             $this->sendToWebSocketUser($from,[
112 111
                 'message'=>$exception->getMessage(),
@@ -150,8 +149,9 @@  discard block
 block discarded – undo
150 149
             $this->error($msg,$from,'You can\'t send a request without the route and the session id !');
151 150
         }
152 151
 
153
-        if(!isset($this->routes[$msg->route]))
154
-            $this->error($msg,$from,'No such route !');
152
+        if(!isset($this->routes[$msg->route])) {
153
+                    $this->error($msg,$from,'No such route !');
154
+        }
155 155
     }
156 156
 
157 157
     /**
Please login to merge, or discard this patch.