Completed
Push — master ( 2f124c...66b0c2 )
by Mohamed
11:36 queued 09:28
created

Category   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 1
c 3
b 0
f 0
lcom 0
cbo 4
dl 0
loc 21
ccs 0
cts 11
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A fetchCategories() 0 13 1
1
<?php
2
3
/*
4
 * This file is part of the Moo\FlashCardBundle package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Moo\FlashCardBundle\Repository;
13
14
use Doctrine\ORM\EntityRepository;
15
use Doctrine\ORM\Query\Expr;
16
17
/**
18
 * Category is a repository class for the card category entity.
19
 *
20
 * @author Mohamed Alsharaf <[email protected]>
21
 */
22
class Category extends EntityRepository
23
{
24
    /**
25
     * Fetch active categories
26
     *
27
     * @return array
28
     */
29
    public function fetchCategories()
30
    {
31
        $builder = $this->getEntityManager()->createQueryBuilder();
32
33
        $builder
34
            ->select('p', 'c')
35
            ->from('MooFlashCardBundle:Category', 'p')
36
            ->join('p.cards', 'c', Expr\Join::WITH, 'c.active = 1')
37
            ->where('p.active = 1')
38
            ->orderBy('p.title', 'ASC');
39
40
        return $builder->getQuery()->getResult();
41
    }
42
}
43