Passed
Push — master ( f66710...6d0cc1 )
by Matt
08:05
created

ImageRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 15
c 2
b 0
f 0
dl 0
loc 26
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findBetweenDates() 0 9 1
A findFromIdOnwards() 0 8 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\Image;
6
use DateTime;
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Doctrine\Persistence\ManagerRegistry;
9
10
/**
11
 * @method Image|null find($id, $lockMode = null, $lockVersion = null)
12
 * @method Image|null findOneBy(array $criteria, array $orderBy = null)
13
 * @method Image[]    findAll()
14
 * @method Image[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class ImageRepository extends ServiceEntityRepository
17
{
18
    public function __construct(ManagerRegistry $registry)
19
    {
20
        parent::__construct($registry, Image::class);
21
    }
22
23
    public function findBetweenDates(DateTime $from, DateTime $to)
24
    {
25
        return $this->createQueryBuilder('i')
26
            ->andWhere('i.capturedAt BETWEEN :from AND :to')
27
            ->setParameter('from', $from)
28
            ->setParameter('to', $to)
29
            ->orderBy('i.capturedAt')
30
            ->getQuery()
31
            ->getResult();
32
    }
33
34
    public function findFromIdOnwards(int $id)
35
    {
36
        return $this->createQueryBuilder('i')
37
            ->andWhere('i.id >= :id')
38
            ->setParameter('id', $id)
39
            ->orderBy('i.id')
40
            ->getQuery()
41
            ->getResult();
42
    }
43
44
45
    // /**
46
    //  * @return Image[] Returns an array of Image objects
47
    //  */
48
    /*
49
    public function findByExampleField($value)
50
    {
51
        return $this->createQueryBuilder('i')
52
            ->andWhere('i.exampleField = :val')
53
            ->setParameter('val', $value)
54
            ->orderBy('i.id', 'ASC')
55
            ->setMaxResults(10)
56
            ->getQuery()
57
            ->getResult()
58
        ;
59
    }
60
    */
61
62
    /*
63
    public function findOneBySomeField($value): ?Image
64
    {
65
        return $this->createQueryBuilder('i')
66
            ->andWhere('i.exampleField = :val')
67
            ->setParameter('val', $value)
68
            ->getQuery()
69
            ->getOneOrNullResult()
70
        ;
71
    }
72
    */
73
}
74