These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\VotingBundle\Repository; |
||
4 | |||
5 | use Doctrine\ORM\EntityRepository; |
||
6 | |||
7 | /** |
||
8 | * AbstractVote Repository class |
||
9 | */ |
||
10 | class AbstractVoteRepository extends EntityRepository |
||
11 | { |
||
12 | /** |
||
13 | * @param string $reference The reference to filter the votes by |
||
14 | * |
||
15 | * @return array Returns an array of votes |
||
16 | */ |
||
17 | public function findByReference($reference) |
||
18 | { |
||
19 | $qb = $this |
||
20 | ->createQueryBuilder('e') |
||
21 | ->where('e.reference = :reference') |
||
22 | ->setParameter('reference', $reference); |
||
23 | |||
24 | return $qb |
||
25 | ->getQuery() |
||
26 | ->getArrayResult(); |
||
27 | } |
||
28 | |||
29 | /** |
||
30 | * @param string $reference The reference to filter the votes by |
||
31 | * |
||
32 | * @return mixed Returns the count of votes |
||
33 | */ |
||
34 | View Code Duplication | public function countByReference($reference) |
|
0 ignored issues
–
show
|
|||
35 | { |
||
36 | $qb = $this |
||
37 | ->createQueryBuilder('e') |
||
38 | ->select('count(e.id)') |
||
39 | ->where('e.reference = :reference') |
||
40 | ->setParameter('reference', $reference); |
||
41 | |||
42 | return $qb |
||
43 | ->getQuery() |
||
44 | ->getSingleScalarResult(); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @param string $reference The reference to filter the votes by |
||
49 | * @param string $ip The ip to filter the votes by |
||
50 | * |
||
51 | * @return mixed Returns the count of votes |
||
52 | */ |
||
53 | View Code Duplication | public function countByReferenceAndByIp($reference, $ip) |
|
0 ignored issues
–
show
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...
|
|||
54 | { |
||
55 | $qb = $this |
||
56 | ->createQueryBuilder('e') |
||
57 | ->select('count(e.id)') |
||
58 | ->where('e.reference = :reference') |
||
59 | ->andWhere('e.ip = :ip') |
||
60 | ->setParameter('ip', $ip) |
||
61 | ->setParameter('reference', $reference); |
||
62 | |||
63 | return $qb |
||
64 | ->getQuery() |
||
65 | ->getSingleScalarResult(); |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @param string $reference The reference to filter the votes by |
||
70 | * |
||
71 | * @return mixed Returns the sum of the values of the votes |
||
72 | */ |
||
73 | View Code Duplication | public function getValueByReference($reference) |
|
0 ignored issues
–
show
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...
|
|||
74 | { |
||
75 | $qb = $this |
||
76 | ->createQueryBuilder('e') |
||
77 | ->select('SUM(e.value)') |
||
78 | ->where('e.reference = :reference') |
||
79 | ->setParameter('reference', $reference); |
||
80 | |||
81 | return $qb |
||
82 | ->getQuery() |
||
83 | ->getSingleScalarResult(); |
||
84 | } |
||
85 | } |
||
86 |
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.