Completed
Push — master ( a7fff6...5ea170 )
by Jeroen
18:57 queued 10s
created

VotingController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 23.53 %

Coupling/Cohesion

Components 1
Dependencies 7

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 7
dl 16
loc 68
ccs 0
cts 32
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A upVoteAction() 8 8 1
A downVoteAction() 8 8 1
A facebookLikeAction() 0 6 1
A facebookSendAction() 0 6 1
A linkedInShareAction() 0 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Kunstmaan\VotingBundle\Controller;
4
5
use Kunstmaan\VotingBundle\Event\Events;
6
use Kunstmaan\VotingBundle\Event\Facebook\FacebookLikeEvent;
7
use Kunstmaan\VotingBundle\Event\Facebook\FacebookSendEvent;
8
use Kunstmaan\VotingBundle\Event\LinkedIn\LinkedInShareEvent;
9
use Kunstmaan\VotingBundle\Event\UpDown\DownVoteEvent;
10
use Kunstmaan\VotingBundle\Event\UpDown\UpVoteEvent;
11
use Symfony\Component\Routing\Annotation\Route;
12
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
13
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
14
use Symfony\Component\HttpFoundation\Request;
15
16
class VotingController extends Controller
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Bundle\Framework...e\Controller\Controller has been deprecated with message: since Symfony 4.2, use "Symfony\Bundle\FrameworkBundle\Controller\AbstractController" instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
17
{
18
    /**
19
     * @Route("/voting-upvote", name="voting_upvote")
20
     * @Template("KunstmaanVotingBundle:UpDown:voted.html.twig")
21
     *
22
     * @param \Symfony\Component\HttpFoundation\Request $request
23
     */
24 View Code Duplication
    public function upVoteAction(Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
    {
26
        $reference = $request->get('reference');
27
        $value = $request->get('value');
28
        $this->get('event_dispatcher')->dispatch(Events::VOTE_UP, new UpVoteEvent($request, $reference, $value));
29
30
        return;
31
    }
32
33
    /**
34
     * @Route("/voting-downvote", name="voting_downvote")
35
     * @Template("KunstmaanVotingBundle:UpDown:voted.html.twig")
36
     *
37
     * @param \Symfony\Component\HttpFoundation\Request $request
38
     */
39 View Code Duplication
    public function downVoteAction(Request $request)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    {
41
        $reference = $request->get('reference');
42
        $value = $request->get('value');
43
        $this->get('event_dispatcher')->dispatch(Events::VOTE_DOWN, new DownVoteEvent($request, $reference, $value));
44
45
        return;
46
    }
47
48
    /**
49
     * @Route("/voting-facebooklike", name="voting_facebooklike")
50
     *
51
     * @param \Symfony\Component\HttpFoundation\Request $request
52
     */
53
    public function facebookLikeAction(Request $request)
54
    {
55
        $response = $request->get('response');
56
        $value = $request->get('value');
57
        $this->get('event_dispatcher')->dispatch(Events::FACEBOOK_LIKE, new FacebookLikeEvent($request, $response, $value));
58
    }
59
60
    /**
61
     * @Route("/voting-facebooksend", name="voting_facebooksend")
62
     *
63
     * @param \Symfony\Component\HttpFoundation\Request $request
64
     */
65
    public function facebookSendAction(Request $request)
66
    {
67
        $response = $request->get('response');
68
        $value = $request->get('value');
69
        $this->get('event_dispatcher')->dispatch(Events::FACEBOOK_SEND, new FacebookSendEvent($request, $response, $value));
70
    }
71
72
    /**
73
     * @Route("/voting-linkedinshare", name="voting_linkedinshare")
74
     *
75
     * @param \Symfony\Component\HttpFoundation\Request $request
76
     */
77
    public function linkedInShareAction(Request $request)
78
    {
79
        $reference = $request->get('reference');
80
        $value = $request->get('value');
81
        $this->get('event_dispatcher')->dispatch(Events::LINKEDIN_SHARE, new LinkedInShareEvent($request, $reference, $value));
82
    }
83
}
84