Passed
Push — master ( 88105a...84be9d )
by Alexey
17:21
created

PostRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getPostWithComments() 0 14 1
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\Repository\Blogs;
4
5
use Doctrine\ORM\EntityRepository;
6
use Doctrine\ORM\QueryBuilder;
7
8
class PostRepository extends EntityRepository
9
{
10 1
    public function getPostWithComments($postId)
11
    {
12
        /** @var QueryBuilder $qb */
13 1
        $qb = $this->createQueryBuilder('p');
14
        return $qb
15 1
            ->select(['p', 'c', 'a'])
16 1
            ->leftJoin('p.comments', 'c')
17 1
            ->leftJoin('c.author', 'a')
18 1
            ->where($qb->expr()->eq('p.id', ':post_id'))
19 1
            ->orderBy('c.number', 'asc')
20 1
            ->setParameter('post_id', $postId)
21 1
            ->getQuery()->getOneOrNullResult()
22
        ;
23
    }
24
}