Code Duplication    Length = 10-10 lines in 4 locations

src/Controller/Admin/UsersController.php 2 locations

@@ 26-35 (lines=10) @@
23
    public function search()
24
    {
25
        //Keyword to search. (For pagination)
26
        if (!empty($this->request->data['search'])) {
27
            $keyword = $this->request->data['search'];
28
            $this->request->session()->write('Search.Admin.Users.Keyword', $keyword);
29
        } else {
30
            if ($this->request->session()->read('Search.Admin.Users.Keyword')) {
31
                $keyword = $this->request->session()->read('Search.Admin.Users.Keyword');
32
            } else {
33
                $keyword = '';
34
            }
35
        }
36
37
        //Search type. (For pagination)
38
        if (!empty($this->request->data['type'])) {
@@ 38-47 (lines=10) @@
35
        }
36
37
        //Search type. (For pagination)
38
        if (!empty($this->request->data['type'])) {
39
            $type = $this->request->data['type'];
40
            $this->request->session()->write('Search.Admin.Users.Type', $type);
41
        } else {
42
            if ($this->request->session()->read('Search.Admin.Users.Type')) {
43
                $type = $this->request->session()->read('Search.Admin.Users.Type');
44
            } else {
45
                $type = '';
46
            }
47
        }
48
49
        switch ($type) {
50
            case "username":

src/Controller/ConversationsController.php 1 location

@@ 1134-1143 (lines=10) @@
1131
        $this->loadModel('ConversationsUsers');
1132
1133
        //Check the keyword to search. (For pagination)
1134
        if (!empty($this->request->data['search'])) {
1135
            $keyword = $this->request->data['search'];
1136
            $this->request->session()->write('Search.Conversations.Keyword', $keyword);
1137
        } else {
1138
            if ($this->request->session()->read('Search.Conversations.Keyword')) {
1139
                $keyword = $this->request->session()->read('Search.Conversations.Keyword');
1140
            } else {
1141
                $keyword = '';
1142
            }
1143
        }
1144
1145
        //Pagination
1146
        $this->paginate = [

src/Controller/BlogController.php 1 location

@@ 423-432 (lines=10) @@
420
        $this->loadModel('BlogArticles');
421
422
        //Check the keyword to search. (For pagination)
423
        if (!empty($this->request->data['search'])) {
424
            $keyword = $this->request->data['search'];
425
            $this->request->session()->write('Search.Blog.Keyword', $keyword);
426
        } else {
427
            if ($this->request->session()->read('Search.Blog.Keyword')) {
428
                $keyword = $this->request->session()->read('Search.Blog.Keyword');
429
            } else {
430
                $keyword = '';
431
            }
432
        }
433
434
        //Pagination
435
        $this->paginate = [