GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

AdminBoardBaseController   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6
Metric Value
wmc 12
lcom 1
cbo 6
dl 0
loc 105
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFormHandlerToCreateBoard() 0 16 3
A getFormHandlerToUpdateBoard() 0 10 1
A getFormHandlerToDeleteBoard() 0 10 1
A getFilterQueryStrings() 0 14 3
B getNormalisedCategoryAndForumFilters() 0 22 4
1
<?php
2
3
/*
4
 * This file is part of the CCDNForum ForumBundle
5
 *
6
 * (c) CCDN (c) CodeConsortium <http://www.codeconsortium.com/>
7
 *
8
 * Available on github <http://www.github.com/codeconsortium/>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace CCDNForum\ForumBundle\Controller;
15
16
use CCDNForum\ForumBundle\Entity\Board;
17
18
/**
19
 *
20
 * @category CCDNForum
21
 * @package  ForumBundle
22
 *
23
 * @author   Reece Fowell <[email protected]>
24
 * @license  http://opensource.org/licenses/MIT MIT
25
 * @version  Release: 2.0
26
 * @link     https://github.com/codeconsortium/CCDNForumForumBundle
27
 *
28
 */
29
class AdminBoardBaseController extends BaseController
30
{
31
    /**
32
     *
33
     * @access protected
34
     * @return \CCDNForum\ForumBundle\Form\Handler\BoardCreateFormHandler
35
     */
36
    protected function getFormHandlerToCreateBoard($categoryFilter = null)
37
    {
38
        $formHandler = $this->container->get('ccdn_forum_forum.form.handler.board_create');
39
40
        $formHandler->setRequest($this->getRequest());
41
42
        if ($categoryFilter) {
43
            $category = $this->getCategoryModel()->findOneCategoryById($categoryFilter);
44
45
            if ($category) {
46
                $formHandler->setDefaultCategory($category);
47
            }
48
        }
49
50
        return $formHandler;
51
    }
52
53
    /**
54
     *
55
     * @access protected
56
     * @return \CCDNForum\ForumBundle\Form\Handler\BoardUpdateFormHandler
57
     */
58
    protected function getFormHandlerToUpdateBoard(Board $board)
59
    {
60
        $formHandler = $this->container->get('ccdn_forum_forum.form.handler.board_update');
61
62
        $formHandler->setRequest($this->getRequest());
63
64
        $formHandler->setBoard($board);
65
66
        return $formHandler;
67
    }
68
69
    /**
70
     *
71
     * @access protected
72
     * @return \CCDNForum\ForumBundle\Form\Handler\BoardDeleteFormHandler
73
     */
74
    protected function getFormHandlerToDeleteBoard(Board $board)
75
    {
76
        $formHandler = $this->container->get('ccdn_forum_forum.form.handler.board_delete');
77
78
        $formHandler->setRequest($this->getRequest());
79
80
        $formHandler->setBoard($board);
81
82
        return $formHandler;
83
    }
84
85
    /**
86
     *
87
     * @access protected
88
     * @param  \CCDNForum\ForumBundle\Entity\Board $board
89
     * @return array
90
     */
91
    protected function getFilterQueryStrings(Board $board)
92
    {
93
        $params = array();
94
95
        if ($board->getCategory()) {
96
            $params['category_filter'] = $board->getCategory()->getId();
97
98
            if ($board->getCategory()->getForum()) {
99
                $params['forum_filter'] = $board->getCategory()->getForum()->getId();
100
            }
101
        }
102
103
        return $params;
104
    }
105
106
    /**
107
     *
108
     * @access protected
109
     * @return array
110
     */
111
    protected function getNormalisedCategoryAndForumFilters()
112
    {
113
        $forumFilter = $this->getQuery('forum_filter', null);
114
        $categoryFilter = $this->getQuery('category_filter', null);
115
116
        if ($categoryFilter) { // Corrective Measure incase forum/category filters fall out of sync.
117
            if ($category = $this->getCategoryModel()->findOneCategoryById($categoryFilter)) {
118
                if ($category->getForum()) {
119
                    $forumFilter = $category->getForum()->getId();
120
                } else {
121
                    $forumFilter = null; // Force it to be blank so 'unassigned' is highlighted.
122
                }
123
            } else {
124
                $forumFilter = null;
125
            }
126
        }
127
128
        return array(
129
            'forum_filter' => $forumFilter,
130
            'category_filter' => $categoryFilter
131
        );
132
    }
133
}
134