CategoryRepository::findOrderedByPosition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace AppBundle\Entity;
4
5
use Doctrine\ORM\EntityRepository;
6
7
class CategoryRepository extends EntityRepository
8
{
9
    public function findOrderedByPosition()
10
    {
11
        return $this
12
            ->createQueryBuilder('c')
13
            ->select('c, m')
14
            ->leftJoin('c.meals', 'm')
15
            ->orderBy('c.position', 'ASC')
16
            ->addOrderBy('m.position', 'ASC')
17
            ->getQuery()
18
            ->getResult()
19
        ;
20
    }
21
22
    public function countAll()
23
    {
24
        return $this
25
            ->createQueryBuilder('c')
26
            ->select('COUNT(c.id)')
27
            ->getQuery()
28
            ->getSingleScalarResult()
29
        ;
30
    }
31
}
32