PerformanceEventRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 92.31%

Importance

Changes 0
Metric Value
dl 0
loc 25
ccs 12
cts 13
cp 0.9231
rs 10
c 0
b 0
f 0
wmc 3
lcom 0
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findByDateRangeAndSlug() 0 17 2
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\PerformanceEvent;
6
use Doctrine\Common\Persistence\ManagerRegistry;
7
8
class PerformanceEventRepository extends AbstractRepository
9
{
10 6
    public function __construct(ManagerRegistry $registry)
11
    {
12 6
        parent::__construct($registry, PerformanceEvent::class);
13 6
    }
14
15 2
    public function findByDateRangeAndSlug(\DateTime $fromDate, \DateTime $toDate, $performanceSlug = null)
16
    {
17 2
        $qb = $this->createQueryBuilder('u')
18 2
            ->WHERE('u.dateTime BETWEEN :from AND :to')
19 2
            ->setParameter('from', $fromDate->format('Y-m-d H:i'))
20 2
            ->setParameter('to', $toDate->format('Y-m-d H:i'))
21 2
            ->orderBy('u.dateTime', 'ASC')
22
        ;
23
24 2
        if ($performanceSlug) {
25
            $qb->join('u.performance', 'p')->andWhere('p.slug = :slug')->setParameter('slug', $performanceSlug);
26
        }
27
28 2
        $query = $qb->getQuery()->enableResultCache(60*60);
29
30 2
        return $query->execute();
31
    }
32
}
33