Completed
Push — 3.x-dev-kit ( 21be5a )
by
unknown
03:10
created

BasePostRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 4
dl 0
loc 32
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findLastPostQueryBuilder() 0 6 1
A countCommentsQuery() 0 8 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[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 Sonata\NewsBundle\Entity;
13
14
use Doctrine\ORM\EntityRepository;
15
16
class BasePostRepository extends EntityRepository
17
{
18
    /**
19
     * return last post query builder.
20
     *
21
     * @param int $limit
22
     *
23
     * @return \Doctrine\ORM\QueryBuilder
24
     */
25
    public function findLastPostQueryBuilder($limit)
0 ignored issues
show
Unused Code introduced by
The parameter $limit is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
26
    {
27
        return $this->createQueryBuilder('p')
28
            ->where('p.enabled = true')
29
            ->orderby('p.createdAt', 'DESC');
30
    }
31
32
    /**
33
     * return count comments QueryBuilder.
34
     *
35
     * @param  Sonata\NewsBundle\Model\PostInterface
36
     *
37
     * @return \Doctrine\ORM\QueryBuilder
38
     */
39
    public function countCommentsQuery($post)
40
    {
41
        return $this->getEntityManager()->createQuery('SELECT COUNT(c.id)
42
                                          FROM Application\Sonata\NewsBundle\Entity\Comment c
43
                                          WHERE c.status = 1
44
                                          AND c.post = :post')
45
                    ->setParameters(array('post' => $post));
46
    }
47
}
48