Completed
Push — master ( aba493...5356ed )
by Ruud
315:38 queued 305:00
created

AbstractVotingHelper::countByReference()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Kunstmaan\VotingBundle\Helper;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
7
/**
8
 * Abstract Helper class for Voting
9
 */
10
abstract class AbstractVotingHelper
11
{
12
    /**
13
     * @var EntityManagerInterface
14
     */
15
    protected $em;
16
17
    /**
18
     * @var string
19
     */
20
    protected $repository;
21
22
    /**
23
     * @param EntityManagerInterface $em
24
     */
25
    public function __construct(EntityManagerInterface $em)
26
    {
27
        $this->em = $em;
28
    }
29
30
    /**
31
     * @param string $reference Reference to filter the votes by
32
     *
33
     * @return array Returns an array of votes
34
     */
35
    public function byReference($reference)
36
    {
37
        return $this->em->getRepository($this->repository)
0 ignored issues
show
Bug introduced by
The method findByReference() does not exist on Doctrine\Common\Persistence\ObjectRepository. Did you maybe mean findBy()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
38
            ->findByReference($reference);
39
    }
40
41
    /**
42
     * @param string $reference The reference to filter the votes by
43
     *
44
     * @return mixed Returns the count
45
     */
46
    public function countByReference($reference)
47
    {
48
        return $this->em->getRepository($this->repository)
49
            ->countByReference($reference);
50
    }
51
52
    /**
53
     * @param string $reference The reference to filter the votes by
54
     *
55
     * @return mixed Returns the sum of the values
56
     */
57
    public function getValueByReference($reference)
58
    {
59
        return $this->em->getRepository($this->repository)
60
            ->getValueByReference($reference);
61
    }
62
}
63