Completed
Pull Request — develop (#39)
by Axel
15:36
created

FeedbackRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 1
lcom 0
cbo 4
dl 0
loc 19
rs 10
c 2
b 0
f 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A countPerStatus() 0 11 1
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