Completed
Push — master ( da46fb...91cc27 )
by Ankit
09:18
created
src/Search.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 namespace ChatApp;
4
-require_once (dirname(__DIR__) . '/vendor/autoload.php');
4
+require_once (dirname(__DIR__).'/vendor/autoload.php');
5 5
 use ChatApp\Time;
6 6
 use Dotenv\Dotenv;
7 7
 $dotenv = new Dotenv(dirname(__DIR__));
@@ -34,20 +34,20 @@  discard block
 block discarded – undo
34 34
         $userId = $suggestion->userId;
35 35
         $suggestion = trim($suggestion->value);
36 36
         $flag = 0;
37
-        if(!empty($userId) && !empty($suggestion))
37
+        if (!empty($userId) && !empty($suggestion))
38 38
         {
39 39
             $query = "SELECT * FROM login where login_id != '$userId' and name like '$suggestion%' ORDER BY name DESC";
40
-            if($result = $this->connect->query($query))
40
+            if ($result = $this->connect->query($query))
41 41
             {
42
-                if($result->num_rows > 0)
42
+                if ($result->num_rows > 0)
43 43
                 {
44
-                    while($row = $result->fetch_assoc())
44
+                    while ($row = $result->fetch_assoc())
45 45
                     {
46 46
                         $check_id = $row["login_id"];
47 47
                         $query = "SELECT * from total_message where (user1 = '$check_id' and user2 = '$userId') or (user2 = '$check_id' and user1 = '$userId')";
48
-                        if($result1 = $this->connect->query($query))
48
+                        if ($result1 = $this->connect->query($query))
49 49
                         {
50
-                            if($result1->num_rows > 0)
50
+                            if ($result1->num_rows > 0)
51 51
                             {
52 52
                                 $fetch = $result1->fetch_assoc();
53 53
                                 $fetch['time'] = $this->obTime->timeConversion($fetch['time']);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                     }
60 60
                 }
61 61
             }
62
-            if($flag != 0)
62
+            if ($flag != 0)
63 63
             {
64 64
                 $this->array = array_merge([], ["Search" => $this->array]);
65 65
                 return json_encode($this->array);
Please login to merge, or discard this patch.
src/Chat.php 2 patches
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 
37 37
     public function onMessage(ConnectionInterface $from, $msg)
38 38
     {
39
-        $msg = (object) json_decode($msg);
40
-        if($msg->type == 'OpenChat initiated..!')
39
+        $msg = (object)json_decode($msg);
40
+        if ($msg->type == 'OpenChat initiated..!')
41 41
         {
42
-            $initial = (object) array();
42
+            $initial = (object)array();
43 43
             $initial->initial = json_decode($this->onSidebar($from->userId));
44 44
 
45
-            if($initial->initial != null)
45
+            if ($initial->initial != null)
46 46
             {
47 47
                 $initial->conversation = json_decode(
48 48
                     $this->onConversation(
@@ -58,14 +58,14 @@  discard block
 block discarded – undo
58 58
         }
59 59
         elseif ($msg->type == 'Load Sidebar')
60 60
         {
61
-            $sidebar = (object) array();
61
+            $sidebar = (object)array();
62 62
             $sidebar->sidebar = json_decode($this->onSidebar($from->userId));
63 63
             $from->send(json_encode($sidebar));
64 64
         }
65 65
         elseif ($msg->type == 'Initiated')
66 66
         {
67 67
             $msg->userId = $from->userId;
68
-            $result = (object) array();
68
+            $result = (object)array();
69 69
             $result->conversation = json_decode($this->onConversation(json_encode($msg), False));
70 70
             $from->send(json_encode($result));
71 71
         }
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
             $getReturn = $this->onReply($msg);
88 88
             echo $getReturn;
89 89
 
90
-            $receiveResult = (object) array();
91
-            $sentResult = (object) array();
90
+            $receiveResult = (object)array();
91
+            $sentResult = (object)array();
92 92
             foreach ($this->clients as $client)
93 93
             {
94 94
                 if ($client->userId == $msg->name)
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
 
108 108
                     $client->send(json_encode($receiveResult));
109 109
                 }
110
-                elseif($client == $from)
110
+                elseif ($client == $from)
111 111
                 {
112 112
                     $sentResult->sidebar = json_decode($this->onSidebar($client->userId));
113 113
 
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -55,33 +55,28 @@  discard block
 block discarded – undo
55 55
                 );
56 56
             }
57 57
             $from->send(json_encode($initial));
58
-        }
59
-        elseif ($msg->type == 'Load Sidebar')
58
+        } elseif ($msg->type == 'Load Sidebar')
60 59
         {
61 60
             $sidebar = (object) array();
62 61
             $sidebar->sidebar = json_decode($this->onSidebar($from->userId));
63 62
             $from->send(json_encode($sidebar));
64
-        }
65
-        elseif ($msg->type == 'Initiated')
63
+        } elseif ($msg->type == 'Initiated')
66 64
         {
67 65
             $msg->userId = $from->userId;
68 66
             $result = (object) array();
69 67
             $result->conversation = json_decode($this->onConversation(json_encode($msg), False));
70 68
             $from->send(json_encode($result));
71
-        }
72
-        elseif ($msg->type == 'Search')
69
+        } elseif ($msg->type == 'Search')
73 70
         {
74 71
             $msg->userId = $from->userId;
75 72
             $searchResult = $this->onSearch($msg);
76 73
             $from->send($searchResult);
77
-        }
78
-        elseif ($msg->type == 'Compose')
74
+        } elseif ($msg->type == 'Compose')
79 75
         {
80 76
             $msg->userId = $from->userId;
81 77
             $composeResult = $this->onCompose($msg);
82 78
             $from->send($composeResult);
83
-        }
84
-        else
79
+        } else
85 80
         {
86 81
             $msg->userId = $from->userId;
87 82
             $getReturn = $this->onReply($msg);
@@ -106,8 +101,7 @@  discard block
 block discarded – undo
106 101
                     );
107 102
 
108 103
                     $client->send(json_encode($receiveResult));
109
-                }
110
-                elseif($client == $from)
104
+                } elseif($client == $from)
111 105
                 {
112 106
                     $sentResult->sidebar = json_decode($this->onSidebar($client->userId));
113 107
 
Please login to merge, or discard this patch.