Completed
Pull Request — develop (#39)
by Axel
02:51
created

FeedbackRepository::countPerStatus()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 11
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 8
nc 1
nop 2
1
<?php
2
3
namespace Developtech\AgilityBundle\Repository;
4
5
use Developtech\AgilityBundle\Model\ProjectModel;
6
7
/**
8
 * FeedbackRepository
9
 *
10
 * This class was generated by the Doctrine ORM. Add your own custom
11
 * repository methods below.
12
 */
13
class FeedbackRepository extends \Doctrine\ORM\EntityRepository
14
{
15
    /**
16
     * @param ProjectModel $project
17
     * @param integer $status
18
     * @return integer
19
     */
20
    public function countPerStatus(ProjectModel $project, $status) {
21
        $statement = $this->getEntityManager()->getConnection()->prepare(
22
            "SELECT COUNT(*) as nb_feedbacks FROM {$this->getClassMetadata()->getTableName()} " .
23
            "WHERE project_id = :project_id AND status = :status"
24
        );
25
        $statement->execute([
26
            'project_id' => $project->getId(),
27
            'status' => $status
28
        ]);
29
        return (int) $statement->fetch()['nb_feedbacks'];
30
    }
31
}
32