Passed
Push — master ( 4cd870...aafdd0 )
by Mohammad
03:37
created
src/Traits/WebSocketMessagesManager.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
      * @param $error
26 26
      * @throws WebSocketException
27 27
      */
28
-    function error($request,ConnectionInterface $from, $error)
28
+    function error($request, ConnectionInterface $from, $error)
29 29
     {
30
-        if(env('APP_DEBUG'))
30
+        if (env('APP_DEBUG'))
31 31
         {
32 32
             echo 'User error: ';
33 33
             echo $error."\n";
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
             'event'=>'error',
40 40
             'message'=>$error
41 41
         ];
42
-        $this->sendToWebSocketUser($from,$data);
42
+        $this->sendToWebSocketUser($from, $data);
43 43
         throw new WebSocketException();
44 44
     }
45 45
 
@@ -47,17 +47,17 @@  discard block
 block discarded – undo
47 47
      * @param ConnectionInterface $conn
48 48
      * @param $data
49 49
      */
50
-    function sendToWebSocketUser(ConnectionInterface $conn,$data)
50
+    function sendToWebSocketUser(ConnectionInterface $conn, $data)
51 51
     {
52
-        if(!is_array($data))
53
-            $data = ['msg'=>$data,'event'=>'default'];
52
+        if (!is_array($data))
53
+            $data = ['msg'=>$data, 'event'=>'default'];
54 54
 
55
-        if(!isset($data['event']))
55
+        if (!isset($data['event']))
56 56
         {
57 57
             $data['event'] = 'default';
58 58
         }
59 59
 
60
-        if(isset($this->route) && !array_key_exists('sender',$data))
60
+        if (isset($this->route) && !array_key_exists('sender', $data))
61 61
             $data['sender'] = $this->getSenderData();
62 62
 
63 63
         $conn->send(json_encode($data));
@@ -68,17 +68,17 @@  discard block
 block discarded – undo
68 68
      * @param array $data
69 69
      * @throws WebSocketException
70 70
      */
71
-    function sendToUser($user_id,$data)
71
+    function sendToUser($user_id, $data)
72 72
     {
73
-        if(!array_key_exists($user_id,$this->userAuthSocketMapper))
73
+        if (!array_key_exists($user_id, $this->userAuthSocketMapper))
74 74
         {
75
-            $this->error($this->request,$this->conn,'No such user !');
75
+            $this->error($this->request, $this->conn, 'No such user !');
76 76
         }
77 77
 
78 78
         $resourceId = $this->userAuthSocketMapper[$user_id];
79 79
         /** @var ConnectionInterface $conn */
80 80
         $conn = $this->clients[$resourceId]->conn;
81
-        $this->sendToWebSocketUser($conn,$data);
81
+        $this->sendToWebSocketUser($conn, $data);
82 82
     }
83 83
 
84 84
     /**
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
      */
87 87
     function sendBack($data)
88 88
     {
89
-       $this->sendToWebSocketUser($this->conn,$data);
89
+       $this->sendToWebSocketUser($this->conn, $data);
90 90
     }
91 91
 
92 92
     /**
Please login to merge, or discard this patch.