Completed
Pull Request — master (#191)
by Serhii
02:32
created

HistoryRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\History;
6
use Doctrine\Common\Persistence\ManagerRegistry;
7
8
class HistoryRepository extends AbstractRepository
9
{
10 6
    public function __construct(ManagerRegistry $registry)
11
    {
12 6
        parent::__construct($registry, History::class);
13 6
    }
14
15 1
    public function findAllHistory($limit, $page)
16
    {
17 1
        $qb = $this->createQueryBuilder('u')
18 1
            ->setMaxResults($limit)
19 1
            ->setFirstResult($page)
20 1
            ->orderBy('u.dateTime', 'DESC')
21
        ;
22
23 1
        $query = $qb->getQuery()->enableResultCache(self::CACHE_TTL);
24
25 1
        return $query->execute();
26
    }
27
28 1 View Code Duplication
    public function getCount()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30 1
        $qb = $this->createQueryBuilder('u');
31 1
        $qb->select($qb->expr()->count('u'));
32
33 1
        $query = $qb->getQuery();
34
35 1
        $query->useResultCache(true, 3600);
0 ignored issues
show
Deprecated Code introduced by
The method Doctrine\ORM\AbstractQuery::useResultCache() has been deprecated with message: 2.7 Use {@see enableResultCache} and {@see disableResultCache} instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
36
37 1
        return $query->getSingleScalarResult();
38
    }
39
}
40