Completed
Push — master ( ae5e03...0447ee )
by Jeroen
10:35 queued 04:37
created

VotingBundle/Helper/AbstractVotingHelper.php (1 issue)

Upgrade to new PHP Analysis Engine

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\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
The method findByReference() does not exist on Doctrine\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