Completed
Push — master ( cf4f4c...f3c478 )
by Julito
36:36
created

CExerciseCategoryRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
dl 0
loc 33
rs 10
c 2
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCourseCount() 0 8 1
A getCategories() 0 8 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CourseBundle\Repository;
5
6
use Chamilo\CoreBundle\Repository\ResourceRepository;
7
8
/**
9
 * Class CExerciseCategoryRepository.
10
 */
11
final class CExerciseCategoryRepository extends ResourceRepository
12
{
13
    /**
14
     * Gets the number of values stored in the table (all fields together)
15
     * for this type of resource.
16
     *
17
     * @param int $courseId
18
     *
19
     * @return int Number of rows in the table
20
     */
21
    public function getCourseCount($courseId)
22
    {
23
        $query = $this->getRepository()->createQueryBuilder('e');
24
        $query->select('count(e.id)');
25
        $query->where('e.cId = :cId');
26
        $query->setParameter('cId', $courseId);
27
28
        return $query->getQuery()->getSingleScalarResult();
29
    }
30
31
    /**
32
     * @param int $courseId
33
     *
34
     * @return array
35
     */
36
    public function getCategories($courseId)
37
    {
38
        $query = $this->getRepository()->createQueryBuilder('e');
39
        $query->where('e.cId = :cId');
40
        $query->setParameter('cId', $courseId);
41
        $query->orderBy('e.position');
42
43
        return $query->getQuery()->getResult();
44
    }
45
}
46