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.

CrumbBuilder   A
last analyzed

Complexity

Total Complexity 28

Size/Duplication

Total Lines 553
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 7
Metric Value
wmc 28
lcom 1
cbo 7
dl 0
loc 553
rs 10

25 Methods

Rating   Name   Duplication   Size   Complexity  
A addAdminIndex() 0 6 1
A addAdminManageForumsIndex() 0 7 1
A addAdminManageForumsCreate() 0 8 1
A addAdminManageForumsEdit() 0 21 1
A addAdminManageForumsDelete() 0 21 1
A addAdminManageCategoriesIndex() 0 7 1
A addAdminManageCategoriesCreate() 0 8 1
A addAdminManageCategoriesEdit() 0 21 1
A addAdminManageCategoriesDelete() 0 21 1
A addAdminManageBoardsIndex() 0 7 1
A addAdminManageBoardsCreate() 0 8 1
A addAdminManageBoardsEdit() 0 21 1
A addAdminManageBoardsDelete() 0 21 1
A addUserCategoryIndex() 0 18 4
A addUserCategoryShow() 0 15 1
A addUserBoardShow() 0 15 1
A addUserTopicShow() 0 15 1
A addUserTopicCreate() 0 17 1
A addUserTopicReply() 0 17 1
A addUserPostShow() 0 15 1
A addUserPostDelete() 0 17 1
A addUserSubscriptionIndex() 0 16 1
A addModeratorTopicDelete() 0 17 1
A addModeratorTopicChangeBoard() 0 17 1
A addModeratorPostUnlock() 0 17 1
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\Component\Crumbs;
15
16
use CCDNForum\ForumBundle\Entity\Forum;
17
use CCDNForum\ForumBundle\Entity\Category;
18
use CCDNForum\ForumBundle\Entity\Board;
19
use CCDNForum\ForumBundle\Entity\Topic;
20
use CCDNForum\ForumBundle\Entity\Post;
21
22
/**
23
 *
24
 * @category CCDNForum
25
 * @package  ForumBundle
26
 *
27
 * @author   Reece Fowell <[email protected]>
28
 * @license  http://opensource.org/licenses/MIT MIT
29
 * @version  Release: 2.0
30
 * @link     https://github.com/codeconsortium/CCDNForumForumBundle
31
 *
32
 */
33
class CrumbBuilder extends BaseCrumbBuilder
34
{
35
    /**
36
     *
37
     * @access public
38
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
39
     */
40
    public function addAdminIndex()
41
    {
42
        return $this->createCrumbTrail()
43
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
44
        ;
45
    }
46
47
    /**
48
     *
49
     * @access public
50
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
51
     */
52
    public function addAdminManageForumsIndex()
53
    {
54
        return $this->createCrumbTrail()
55
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
56
            ->add('crumbs.admin.manage-forums.index', 'ccdn_forum_admin_forum_list')
57
        ;
58
    }
59
60
    /**
61
     *
62
     * @access public
63
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
64
     */
65
    public function addAdminManageForumsCreate()
66
    {
67
        return $this->createCrumbTrail()
68
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
69
            ->add('crumbs.admin.manage-forums.index', 'ccdn_forum_admin_forum_list')
70
            ->add('crumbs.admin.manage-forums.create', 'ccdn_forum_admin_forum_create')
71
        ;
72
    }
73
74
    /**
75
     *
76
     * @access public
77
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
78
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
79
     */
80
    public function addAdminManageForumsEdit(Forum $forum)
81
    {
82
        return $this->createCrumbTrail()
83
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
84
            ->add('crumbs.admin.manage-forums.index', 'ccdn_forum_admin_forum_list')
85
            ->add(
86
                array(
87
                    'label' => 'crumbs.admin.manage-forums.edit',
88
                    'params' => array(
89
                        '%forum_name%' => $forum->getName()
90
                    )
91
                ),
92
                array(
93
                    'route' => 'ccdn_forum_admin_forum_edit',
94
                    'params' => array(
95
                        'forumId' => $forum->getId()
96
                    )
97
                )
98
            )
99
        ;
100
    }
101
102
    /**
103
     *
104
     * @access public
105
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
106
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
107
     */
108
    public function addAdminManageForumsDelete(Forum $forum)
109
    {
110
        return $this->createCrumbTrail()
111
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
112
            ->add('crumbs.admin.manage-forums.index', 'ccdn_forum_admin_forum_list')
113
            ->add(
114
                array(
115
                    'label' => 'crumbs.admin.manage-forums.delete',
116
                    'params' => array(
117
                        '%forum_name%' => $forum->getName()
118
                    )
119
                ),
120
                array(
121
                    'route' => 'ccdn_forum_admin_forum_delete',
122
                    'params' => array(
123
                        'forumId' => $forum->getId()
124
                    )
125
                )
126
            )
127
        ;
128
    }
129
130
    /**
131
     *
132
     * @access public
133
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
134
     */
135
    public function addAdminManageCategoriesIndex()
136
    {
137
        return $this->createCrumbTrail()
138
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
139
            ->add('crumbs.admin.manage-categories.index', 'ccdn_forum_admin_category_list')
140
        ;
141
    }
142
143
    /**
144
     *
145
     * @access public
146
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
147
     */
148
    public function addAdminManageCategoriesCreate()
149
    {
150
        return $this->createCrumbTrail()
151
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
152
            ->add('crumbs.admin.manage-categories.index', 'ccdn_forum_admin_category_list')
153
            ->add('crumbs.admin.manage-categories.create', 'ccdn_forum_admin_category_create')
154
        ;
155
    }
156
157
    /**
158
     *
159
     * @access public
160
     * @param  \CCDNForum\ForumBundle\Entity\Category                     $category
161
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
162
     */
163
    public function addAdminManageCategoriesEdit(Category $category)
164
    {
165
        return $this->createCrumbTrail()
166
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
167
            ->add('crumbs.admin.manage-categories.index', 'ccdn_forum_admin_category_list')
168
            ->add(
169
                array(
170
                    'label' => 'crumbs.admin.manage-categories.edit',
171
                    'params' => array(
172
                        '%category_name%' => $category->getName()
173
                    )
174
                ),
175
                array(
176
                    'route' => 'ccdn_forum_admin_category_edit',
177
                    'params' => array(
178
                        'categoryId' => $category->getId()
179
                    )
180
                )
181
            )
182
        ;
183
    }
184
185
    /**
186
     *
187
     * @access public
188
     * @param  \CCDNForum\ForumBundle\Entity\Category                     $category
189
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
190
     */
191
    public function addAdminManageCategoriesDelete(Category $category)
192
    {
193
        return $this->createCrumbTrail()
194
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
195
            ->add('crumbs.admin.manage-categories.index', 'ccdn_forum_admin_category_list')
196
            ->add(
197
                array(
198
                    'label' => 'crumbs.admin.manage-categories.delete',
199
                    'params' => array(
200
                        '%category_name%' => $category->getName()
201
                    )
202
                ),
203
                array(
204
                    'route' => 'ccdn_forum_admin_category_delete',
205
                    'params' => array(
206
                        'categoryId' => $category->getId()
207
                    )
208
                )
209
            )
210
        ;
211
    }
212
213
    /**
214
     *
215
     * @access public
216
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
217
     */
218
    public function addAdminManageBoardsIndex()
219
    {
220
        return $this->createCrumbTrail()
221
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
222
            ->add('crumbs.admin.manage-boards.index', 'ccdn_forum_admin_board_list')
223
        ;
224
    }
225
226
    /**
227
     *
228
     * @access public
229
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
230
     */
231
    public function addAdminManageBoardsCreate()
232
    {
233
        return $this->createCrumbTrail()
234
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
235
            ->add('crumbs.admin.manage-boards.index', 'ccdn_forum_admin_board_list')
236
            ->add('crumbs.admin.manage-boards.create', 'ccdn_forum_admin_board_create')
237
        ;
238
    }
239
240
    /**
241
     *
242
     * @access public
243
     * @param  \CCDNForum\ForumBundle\Entity\Board                        $board
244
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
245
     */
246
    public function addAdminManageBoardsEdit(Board $board)
247
    {
248
        return $this->createCrumbTrail()
249
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
250
            ->add('crumbs.admin.manage-boards.index', 'ccdn_forum_admin_board_list')
251
            ->add(
252
                array(
253
                    'label' => 'crumbs.admin.manage-boards.edit',
254
                    'params' => array(
255
                        '%board_name%' => $board->getName()
256
                    )
257
                ),
258
                array(
259
                    'route' => 'ccdn_forum_admin_board_edit',
260
                    'params' => array(
261
                        'boardId' => $board->getId()
262
                    )
263
                )
264
            )
265
        ;
266
    }
267
268
    /**
269
     *
270
     * @access public
271
     * @param  \CCDNForum\ForumBundle\Entity\Board                        $board
272
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
273
     */
274
    public function addAdminManageBoardsDelete(Board $board)
275
    {
276
        return $this->createCrumbTrail()
277
            ->add('crumbs.admin.index', 'ccdn_forum_admin_index')
278
            ->add('crumbs.admin.manage-boards.index', 'ccdn_forum_admin_board_list')
279
            ->add(
280
                array(
281
                    'label' => 'crumbs.admin.manage-boards.delete',
282
                    'params' => array(
283
                        '%board_name%' => $board->getName()
284
                    )
285
                ),
286
                array(
287
                    'route' => 'ccdn_forum_admin_board_delete',
288
                    'params' => array(
289
                        'boardId' => $board->getId()
290
                    )
291
                )
292
            )
293
        ;
294
    }
295
296
    /**
297
     *
298
     * @access public
299
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
0 ignored issues
show
Documentation introduced by
Should the type for parameter $forum not be null|Forum?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
300
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
301
     */
302
    public function addUserCategoryIndex(Forum $forum = null)
303
    {
304
        return $this->createCrumbTrail()
305
            ->add(
306
                $forum ?
307
                    $forum->getName() == 'default' ?  'Index' : $forum->getName() . ' Index'
308
                    :
309
                    'Index'
310
                ,
311
                array(
312
                    'route' => 'ccdn_forum_user_category_index',
313
                    'params' => array(
314
                        'forumName' => $forum ? $forum->getName() : 'default'
315
                    )
316
                )
317
            )
318
        ;
319
    }
320
321
    /**
322
     *
323
     * @access public
324
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
325
     * @param  \CCDNForum\ForumBundle\Entity\Category                     $category
326
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
327
     */
328
    public function addUserCategoryShow(Forum $forum, Category $category)
329
    {
330
        return $this->addUserCategoryIndex($forum)
331
            ->add(
332
                $category->getName(),
333
                array(
334
                    'route' => 'ccdn_forum_user_category_show',
335
                    'params' => array(
336
                        'forumName' => $forum->getName(),
337
                        'categoryId' => $category->getId()
338
                    )
339
                )
340
            )
341
        ;
342
    }
343
344
    /**
345
     *
346
     * @access public
347
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
348
     * @param  \CCDNForum\ForumBundle\Entity\Board                        $board
349
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
350
     */
351
    public function addUserBoardShow(Forum $forum, Board $board)
352
    {
353
        return $this->addUserCategoryShow($forum, $board->getCategory())
0 ignored issues
show
Compatibility introduced by
$board->getCategory() of type object<CCDNForum\ForumBu...\Entity\Model\Category> is not a sub-type of object<CCDNForum\ForumBundle\Entity\Category>. It seems like you assume a child class of the class CCDNForum\ForumBundle\Entity\Model\Category to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
354
            ->add(
355
                $board->getName(),
356
                array(
357
                    'route' => 'ccdn_forum_user_board_show',
358
                    'params' => array(
359
                        'forumName' => $forum->getName(),
360
                        'boardId' => $board->getId()
361
                    )
362
                )
363
            )
364
        ;
365
    }
366
367
    /**
368
     *
369
     * @access public
370
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
371
     * @param  \CCDNForum\ForumBundle\Entity\Topic                        $topic
372
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
373
     */
374
    public function addUserTopicShow(Forum $forum, Topic $topic)
375
    {
376
        return $this->addUserBoardShow($forum, $topic->getBoard())
0 ignored issues
show
Compatibility introduced by
$topic->getBoard() of type object<CCDNForum\ForumBundle\Entity\Model\Board> is not a sub-type of object<CCDNForum\ForumBundle\Entity\Board>. It seems like you assume a child class of the class CCDNForum\ForumBundle\Entity\Model\Board to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
377
            ->add(
378
                $topic->getTitle(),
379
                array(
380
                    'route' => 'ccdn_forum_user_topic_show',
381
                    'params' => array(
382
                        'forumName' => $forum->getName(),
383
                        'topicId' => $topic->getId()
384
                    )
385
                )
386
            )
387
        ;
388
    }
389
390
    /**
391
     *
392
     * @access public
393
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
394
     * @param  \CCDNForum\ForumBundle\Entity\Board                        $board
395
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
396
     */
397
    public function addUserTopicCreate(Forum $forum, Board $board)
398
    {
399
        return $this->addUserBoardShow($forum, $board)
400
            ->add(
401
                array(
402
                    'label' => 'crumbs.user.topic.create',
403
                ),
404
                array(
405
                    'route' => 'ccdn_forum_user_topic_create',
406
                    'params' => array(
407
                        'forumName' => $forum->getName(),
408
                        'boardId' => $board->getId()
409
                    )
410
                )
411
            )
412
        ;
413
    }
414
415
    /**
416
     *
417
     * @access public
418
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
419
     * @param  \CCDNForum\ForumBundle\Entity\Topic                        $topic
420
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
421
     */
422
    public function addUserTopicReply(Forum $forum, Topic $topic)
423
    {
424
        return $this->addUserTopicShow($forum, $topic)
425
            ->add(
426
                array(
427
                    'label' => 'crumbs.user.topic.reply',
428
                ),
429
                array(
430
                    'route' => 'ccdn_forum_user_topic_reply',
431
                    'params' => array(
432
                        'forumName' => $forum->getName(),
433
                        'topicId' => $topic->getId()
434
                    )
435
                )
436
            )
437
        ;
438
    }
439
440
    /**
441
     *
442
     * @access public
443
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
444
     * @param  \CCDNForum\ForumBundle\Entity\Post                         $post
445
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
446
     */
447
    public function addUserPostShow(Forum $forum, Post $post)
448
    {
449
        return $this->addUserTopicShow($forum, $post->getTopic())
0 ignored issues
show
Compatibility introduced by
$post->getTopic() of type object<CCDNForum\ForumBundle\Entity\Model\Topic> is not a sub-type of object<CCDNForum\ForumBundle\Entity\Topic>. It seems like you assume a child class of the class CCDNForum\ForumBundle\Entity\Model\Topic to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
450
            ->add(
451
                '# ' . $post->getId(),
452
                array(
453
                    'route' => 'ccdn_forum_user_post_show',
454
                    'params' => array(
455
                        'forumName' => $forum->getName(),
456
                        'postId' => $post->getId()
457
                    )
458
                )
459
            )
460
        ;
461
    }
462
463
    /**
464
     *
465
     * @access public
466
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
467
     * @param  \CCDNForum\ForumBundle\Entity\Post                         $post
468
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
469
     */
470
    public function addUserPostDelete(Forum $forum, Post $post)
471
    {
472
        return $this->addUserPostShow($forum, $post)
473
            ->add(
474
                array(
475
                    'label' => 'crumbs.user.post.delete',
476
                ),
477
                array(
478
                    'route' => 'ccdn_forum_user_post_delete',
479
                    'params' => array(
480
                        'forumName' => $forum->getName(),
481
                        'postId' => $post->getId()
482
                    )
483
                )
484
            )
485
        ;
486
    }
487
488
    /**
489
     *
490
     * @access public
491
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
492
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
493
     */
494
    public function addUserSubscriptionIndex(Forum $forum)
495
    {
496
        return $this->addUserCategoryIndex($forum)
497
            ->add(
498
                array(
499
                    'label' => 'crumbs.user.subscription.index',
500
                ),
501
                array(
502
                    'route' => 'ccdn_forum_user_subscription_index',
503
                    'params' => array(
504
                        'forumName' => $forum->getName()
505
                    )
506
                )
507
            )
508
        ;
509
    }
510
511
    /**
512
     *
513
     * @access public
514
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
515
     * @param  \CCDNForum\ForumBundle\Entity\Topic                        $topic
516
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
517
     */
518
    public function addModeratorTopicDelete(Forum $forum, Topic $topic)
519
    {
520
        return $this->addUserTopicShow($forum, $topic)
521
            ->add(
522
                array(
523
                    'label' => 'crumbs.moderator.topic.delete',
524
                ),
525
                array(
526
                    'route' => 'ccdn_forum_moderator_topic_delete',
527
                    'params' => array(
528
                        'forumName' => $forum->getName(),
529
                        'topicId'   => $topic->getId()
530
                    )
531
                )
532
            )
533
        ;
534
    }
535
536
    /**
537
     *
538
     * @access public
539
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
540
     * @param  \CCDNForum\ForumBundle\Entity\Topic                        $topic
541
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
542
     */
543
    public function addModeratorTopicChangeBoard(Forum $forum, Topic $topic)
544
    {
545
        return $this->addUserTopicShow($forum, $topic)
546
            ->add(
547
                array(
548
                    'label' => 'crumbs.moderator.topic.move',
549
                ),
550
                array(
551
                    'route' => 'ccdn_forum_moderator_topic_change_board',
552
                    'params' => array(
553
                        'forumName' => $forum->getName(),
554
                        'topicId'   => $topic->getId()
555
                    )
556
                )
557
            )
558
        ;
559
    }
560
561
    /**
562
     *
563
     * @access public
564
     * @param  \CCDNForum\ForumBundle\Entity\Forum                        $forum
565
     * @param  \CCDNForum\ForumBundle\Entity\Post                         $post
566
     * @return \CCDNForum\ForumBundle\Component\Crumbs\Factory\CrumbTrail
567
     */
568
    public function addModeratorPostUnlock(Forum $forum, Post $post)
569
    {
570
        return $this->addUserPostShow($forum, $post)
571
            ->add(
572
                array(
573
                    'label' => 'crumbs.moderator.post.unlock',
574
                ),
575
                array(
576
                    'route' => 'ccdn_forum_moderator_post_unlock',
577
                    'params' => array(
578
                        'forumName' => $forum->getName(),
579
                        'postId'   => $post->getId()
580
                    )
581
                )
582
            )
583
        ;
584
    }
585
}
586