AuthorRepository   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 18
ccs 0
cts 9
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAllWithPublishedPosts() 0 11 1
1
<?php
2
3
namespace Smart\ContentBundle\Entity\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
use Smart\ContentBundle\Entity\Author;
7
8
/**
9
 * Nicolas Bastien <[email protected]>
10
 */
11
class AuthorRepository extends EntityRepository
12
{
13
    /**
14
     * @param int|null $limit
15
     * @return Author[]
16
     */
17
    public function getAllWithPublishedPosts($limit = null)
18
    {
19
        return $this->createQueryBuilder('a')
20
            ->leftJoin('a.posts', 'p')
21
            ->andWhere('p.publishedAt IS NOT NULL')
22
            ->andWhere('p.enabled = 1')
23
            ->orderBy('a.title', 'ASC')
24
            ->setMaxResults($limit)
25
            ->getQuery()
26
            ->getResult();
27
    }
28
}
29