Test Setup Failed
Pull Request — master (#15)
by Stone
05:06 queued 01:55
created

TrickRepository::findLatestEdited()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\Trick;
6
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
7
use Symfony\Bridge\Doctrine\RegistryInterface;
8
9
/**
10
 * @method Trick|null find($id, $lockMode = null, $lockVersion = null)
11
 * @method Trick|null findOneBy(array $criteria, array $orderBy = null)
12
 * @method Trick[]    findAll()
13
 * @method Trick[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
14
 */
15
class TrickRepository extends ServiceEntityRepository
16
{
17
    public function __construct(RegistryInterface $registry)
18
    {
19
        parent::__construct($registry, Trick::class);
20
    }
21
22
    /**
23
     * @return Trick[] Returns an array of Trick objects
24
     */
25
    public function findLatestEdited($limit = Trick::NUMBER_OF_DISPLAYED_TRICKS)
26
    {
27
        return $this->createQueryBuilder('t')
28
            ->orderBy('t.editedAt', 'DESC')
29
            ->setMaxResults($limit)
30
            ->getQuery()
31
            ->getResult();
32
    }
33
}
34