Passed
Push — master ( 1b6703...425d4d )
by Mohammad
04:36
created
src/Facades/WsRoute.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
 
11 11
 class WsRoute extends \Illuminate\Support\Facades\Facade
12 12
 {
13
-    static function getFacadeAccessor(){
13
+    static function getFacadeAccessor() {
14 14
 
15 15
         return 'WsRoute';
16 16
     }
Please login to merge, or discard this patch.
src/Objects/Rooms/Room.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@
 block discarded – undo
44 44
 
45 45
     function hasMember($client)
46 46
     {
47
-        if(array_key_exists($client->id,$this->members))
47
+        if (array_key_exists($client->id, $this->members))
48 48
             return true;
49 49
 
50 50
         return false;
Please login to merge, or discard this 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/WebSocketMessagesManager.php 4 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@
 block discarded – undo
72 72
      */
73 73
     function sendBack($data)
74 74
     {
75
-       $this->sendToWebSocketUser($this->conn,$data);
75
+        $this->sendToWebSocketUser($this->conn,$data);
76 76
     }
77 77
 
78 78
     /**
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -49,16 +49,18 @@
 block discarded – undo
49 49
      */
50 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
 
55 56
         if(!isset($data['event']))
56 57
         {
57 58
             $data['event'] = 'default';
58 59
         }
59 60
 
60
-        if(isset($this->route) && !array_key_exists('sender',$data))
61
-            $data['sender'] = $this->getSenderData();
61
+        if(isset($this->route) && !array_key_exists('sender',$data)) {
62
+                    $data['sender'] = $this->getSenderData();
63
+        }
62 64
 
63 65
         $conn->send(json_encode($data));
64 66
     }
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
     /**
22 22
      * @param $request
23 23
      * @param ConnectionInterface $from
24
-     * @param $error
24
+     * @param string $error
25 25
      * @throws WebSocketException
26 26
      */
27 27
     function error($request,ConnectionInterface $from, $error)
@@ -101,6 +101,9 @@  discard block
 block discarded – undo
101 101
         ];
102 102
     }
103 103
 
104
+    /**
105
+     * @param integer $user_id
106
+     */
104 107
     function isOnline($user_id)
105 108
     {
106 109
         if(array_key_exists($user_id,$this->userAuthSocketMapper))
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
      * @param $error
25 25
      * @throws WebSocketException
26 26
      */
27
-    function error($request,ConnectionInterface $from, $error)
27
+    function error($request, ConnectionInterface $from, $error)
28 28
     {
29
-        if(env('APP_DEBUG'))
29
+        if (env('APP_DEBUG'))
30 30
         {
31 31
             echo 'User error: ';
32 32
             echo $error."\n";
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
             'event'=>'error',
39 39
             'message'=>$error
40 40
         ];
41
-        $this->sendToWebSocketUser($from,$data);
41
+        $this->sendToWebSocketUser($from, $data);
42 42
         throw new WebSocketException();
43 43
     }
44 44
 
@@ -46,17 +46,17 @@  discard block
 block discarded – undo
46 46
      * @param ConnectionInterface $conn
47 47
      * @param $data
48 48
      */
49
-    function sendToWebSocketUser(ConnectionInterface $conn,$data)
49
+    function sendToWebSocketUser(ConnectionInterface $conn, $data)
50 50
     {
51
-        if(!is_array($data))
52
-            $data = ['msg'=>$data,'event'=>'default'];
51
+        if (!is_array($data))
52
+            $data = ['msg'=>$data, 'event'=>'default'];
53 53
 
54
-        if(!isset($data['event']))
54
+        if (!isset($data['event']))
55 55
         {
56 56
             $data['event'] = 'default';
57 57
         }
58 58
 
59
-        if(isset($this->route) && !array_key_exists('sender',$data))
59
+        if (isset($this->route) && !array_key_exists('sender', $data))
60 60
             $data['sender'] = $this->getSenderData();
61 61
 
62 62
         $conn->send(json_encode($data));
@@ -67,9 +67,9 @@  discard block
 block discarded – undo
67 67
      * @param array $data
68 68
      * @return bool
69 69
      */
70
-    function sendToUser($user_id,$data)
70
+    function sendToUser($user_id, $data)
71 71
     {
72
-        if(!$this->isOnline($user_id))
72
+        if (!$this->isOnline($user_id))
73 73
         {
74 74
             return false;
75 75
         }
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
         $resourceId = $this->userAuthSocketMapper[$user_id];
78 78
         /** @var ConnectionInterface $conn */
79 79
         $conn = $this->clients[$resourceId]->conn;
80
-        $this->sendToWebSocketUser($conn,$data);
80
+        $this->sendToWebSocketUser($conn, $data);
81 81
         return true;
82 82
     }
83 83
 
@@ -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
     /**
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 
104 104
     function isOnline($user_id)
105 105
     {
106
-        if(array_key_exists($user_id,$this->userAuthSocketMapper))
106
+        if (array_key_exists($user_id, $this->userAuthSocketMapper))
107 107
         {
108 108
             return true;
109 109
         }
Please login to merge, or discard this patch.
src/Controllers/WebSocketController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@
 block discarded – undo
22 22
  */
23 23
 class WebSocketController
24 24
 {
25
-    use WebSocketMessagesManager,Validation;
25
+    use WebSocketMessagesManager, Validation;
26 26
 
27 27
     /**
28 28
      * @var Client[]
Please login to merge, or discard this patch.
src/Controllers/RoomController.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,12 +20,12 @@  discard block
 block discarded – undo
20 20
      */
21 21
     function enterRoom()
22 22
     {
23
-        $this->validate($this->request,[
23
+        $this->validate($this->request, [
24 24
             'room_id'=>'required'
25 25
         ]);
26
-        $room_id =$this->request->room_id;
26
+        $room_id = $this->request->room_id;
27 27
 
28
-        $this->validateRoom($room_id,true);
28
+        $this->validateRoom($room_id, true);
29 29
 
30 30
         $this->addMember($room_id);
31 31
     }
@@ -36,10 +36,10 @@  discard block
 block discarded – undo
36 36
     function exitRoom()
37 37
     {
38 38
 
39
-        $this->validate($this->request,[
39
+        $this->validate($this->request, [
40 40
             'room_id'=>'required'
41 41
         ]);
42
-        $room_id =$this->request->room_id;
42
+        $room_id = $this->request->room_id;
43 43
 
44 44
         $this->validateRoom($room_id);
45 45
 
Please login to merge, or discard this patch.
src/Controllers/InitializeController.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,6 +18,6 @@
 block discarded – undo
18 18
     function index()
19 19
     {
20 20
         echo 'Initializing ..';
21
-        $this->sendBack(['message'=>'WebSocket Initialized','event'=>'initialize']);
21
+        $this->sendBack(['message'=>'WebSocket Initialized', 'event'=>'initialize']);
22 22
     }
23 23
 }
24 24
\ No newline at end of file
Please login to merge, or discard this patch.
src/LaravelRatchetServiceProvider.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
         $this->publishes([
29 29
             __DIR__.'/config' => realpath('config'),
30 30
             __DIR__.'/Routes/published' => realpath('routes'),
31
-        ],'laravel-ratchet');
31
+        ], 'laravel-ratchet');
32 32
 
33 33
         if ($this->app['config']->get('laravel-ratchet') === null) {
34 34
             $this->app['config']->set('laravel-ratchet', require __DIR__.'/config/laravel-ratchet.php');
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
      */
43 43
     public function register()
44 44
     {
45
-        $this->app->bind('WsRoute',function (){
45
+        $this->app->bind('WsRoute', function() {
46 46
             return new Routes();
47 47
         });
48 48
     }
Please login to merge, or discard this patch.
src/Controllers/ChatController.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -20,15 +20,15 @@  discard block
 block discarded – undo
20 20
      */
21 21
     function sendMessageToUser()
22 22
     {
23
-        $this->validate($this->request,[
23
+        $this->validate($this->request, [
24 24
             'user_id'=>'required',
25 25
             'message' => 'required'
26 26
         ]);
27 27
 
28 28
         $user_id = $this->request->user_id;
29
-        $data = ['message'=>$this->request->message,'event'=>'receivedMessage'];
29
+        $data = ['message'=>$this->request->message, 'event'=>'receivedMessage'];
30 30
 
31
-        $this->sendToUser($user_id,$data);
31
+        $this->sendToUser($user_id, $data);
32 32
     }
33 33
 
34 34
     /**
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
      */
37 37
     function sendMessageToRoom()
38 38
     {
39
-        $this->validate($this->request,[
39
+        $this->validate($this->request, [
40 40
             'room_id'=>'required',
41 41
             'message' => 'required'
42 42
         ]);
43 43
         $room_id = $this->request->room_id;
44
-        $data = ['message'=>$this->request->message,'event'=>'RoomMessage'];
45
-        $this->sendToRoom($room_id,$data);
44
+        $data = ['message'=>$this->request->message, 'event'=>'RoomMessage'];
45
+        $this->sendToRoom($room_id, $data);
46 46
     }
47 47
 }
48 48
\ No newline at end of file
Please login to merge, or discard this patch.
src/Traits/Validation.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@
 block discarded – undo
39 39
     /**
40 40
      * Validate the given request with the given rules.
41 41
      *
42
-     * @param  object  $request
42
+     * @param  Collection  $request
43 43
      * @param  array  $rules
44 44
      * @param  array  $messages
45 45
      * @param  array  $customAttributes
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@
 block discarded – undo
48 48
      * @throws \Illuminate\Validation\ValidationException
49 49
      */
50 50
     public function validate($request, array $rules,
51
-                             array $messages = [], array $customAttributes = [])
51
+                                array $messages = [], array $customAttributes = [])
52 52
     {
53 53
         if($request instanceof Collection)
54 54
             $request = $request->toArray();
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -20,9 +20,9 @@  discard block
 block discarded – undo
20 20
     {
21 21
         foreach ($required as $input)
22 22
         {
23
-            if(!in_array($input,(array)$this->request))
23
+            if (!in_array($input, (array) $this->request))
24 24
             {
25
-                $this->error($this->request,$this->conn,$this->requireErrorMessage($input));
25
+                $this->error($this->request, $this->conn, $this->requireErrorMessage($input));
26 26
             }
27 27
         }
28 28
     }
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
     public function validate($request, array $rules,
51 51
                              array $messages = [], array $customAttributes = [])
52 52
     {
53
-        if($request instanceof Collection)
53
+        if ($request instanceof Collection)
54 54
             $request = $request->toArray();
55 55
 
56 56
         return $this->getValidationFactory()->make(
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -50,8 +50,9 @@
 block discarded – undo
50 50
     public function validate($request, array $rules,
51 51
                              array $messages = [], array $customAttributes = [])
52 52
     {
53
-        if($request instanceof Collection)
54
-            $request = $request->toArray();
53
+        if($request instanceof Collection) {
54
+                    $request = $request->toArray();
55
+        }
55 56
 
56 57
         return $this->getValidationFactory()->make(
57 58
             (array) $request, $rules, $messages, $customAttributes
Please login to merge, or discard this patch.