Code Duplication    Length = 16-16 lines in 3 locations

controller/main.php 3 locations

@@ 164-179 (lines=16) @@
161
        return new JsonResponse($response, 200);
162
    }
163
164
    public function load()
165
    {
166
        /* AJAX check  */
167
        $http_request = $this->request->server('HTTP_X_REQUESTED_WITH');
168
        if (empty($http_request) && strtolower($http_request) != 'xmlhttprequest') {
169
            return new Response("The request is invalid", 500);
170
        }
171
172
        $friend_id = $this->request->variable('friend_id', 0);
173
174
        if ($friend_id > 0) {
175
            $messages = $this->model->getMessages($friend_id);
176
            return new JsonResponse($messages, 200);
177
        }
178
        return new JsonResponse(array('success' => false, 'error' => 'The request is invalid'), 200);
179
    }
180
181
    public function updateMessages()
182
    {
@@ 181-196 (lines=16) @@
178
        return new JsonResponse(array('success' => false, 'error' => 'The request is invalid'), 200);
179
    }
180
181
    public function updateMessages()
182
    {
183
        /* AJAX check  */
184
        $http_request = $this->request->server('HTTP_X_REQUESTED_WITH');
185
        if (empty($http_request) && strtolower($http_request) != 'xmlhttprequest') {
186
            return new Response("The request is invalid", 500);
187
        }
188
189
        $friend_id = $this->request->variable('friend_id', 0);
190
        if ($friend_id > 0) {
191
            $newVal = $this->model->updateMessagesStatus($friend_id);
192
            return new JsonResponse(array('success' => true, 'newVal' => $newVal), 200);
193
        }
194
        return new JsonResponse(array('success' => false), 200);
195
    }
196
197
    public function checkForNewMessages()
198
    {
199
        /* AJAX check  */
@@ 197-212 (lines=16) @@
194
        return new JsonResponse(array('success' => false), 200);
195
    }
196
197
    public function checkForNewMessages()
198
    {
199
        /* AJAX check  */
200
        $http_request = $this->request->server('HTTP_X_REQUESTED_WITH');
201
        if (empty($http_request) && strtolower($http_request) != 'xmlhttprequest') {
202
            return new Response("The request is invalid", 500);
203
        }
204
205
        $friend_id = $this->request->variable('friend_id', 0);
206
        if ($friend_id > 0) {
207
            $messages = $this->model->getInboxFromId($friend_id);
208
            return new JsonResponse(array('success' => true, 'messages' => $messages), 200);
209
        }
210
        return new JsonResponse(array('success' => false), 200);
211
    }
212
213
    public function getFriends()
214
    {
215
        /* AJAX check  */