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->getData('search'))) {
27
            $keyword = $this->request->getData('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->getData('type'))) {
@@ 38-47 (lines=10) @@
35
        }
36
37
        //Search type. (For pagination)
38
        if (!empty($this->request->getData('type'))) {
39
            $type = $this->request->getData('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

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

src/Controller/BlogController.php 1 location

@@ 461-470 (lines=10) @@
458
        $this->loadModel('BlogArticles');
459
460
        //Check the keyword to search. (For pagination)
461
        if (!empty($this->request->getData('search'))) {
462
            $keyword = $this->request->getData('search');
463
            $this->request->session()->write('Search.Blog.Keyword', $keyword);
464
        } else {
465
            if ($this->request->session()->read('Search.Blog.Keyword')) {
466
                $keyword = $this->request->session()->read('Search.Blog.Keyword');
467
            } else {
468
                $keyword = '';
469
            }
470
        }
471
472
        //Pagination
473
        $this->paginate = [