FeedbackRepository::countPerStatus()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

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