Completed
Push — master ( 30a2b5...89612e )
by Axel
02:59
created

SprintRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 18
dl 0
loc 27
ccs 0
cts 19
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSprintByPeriod() 0 11 1
A getCurrentSprint() 0 12 1
1
<?php
2
3
namespace Scrumban\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
7
class SprintRepository extends EntityRepository
8
{
9
    public function getCurrentSprint()
10
    {
11
        $now = new \DateTime();
12
        return $this->createQueryBuilder('s')
13
            ->where('s.beginAt <= :begin_at')
14
            ->andWhere('s.endedAt >= :ended_at')
15
            ->setParameters([
16
                'begin_at' => $now->format('Y-m-d H:i:s'),
17
                'ended_at' => $now->format('Y-m-d H:i:s')
18
            ])
19
            ->getQuery()
20
            ->getOneOrNullResult();
21
    }
22
    
23
    public function getSprintByPeriod(\DateTime $beginAt, \DateTime $endedAt)
24
    {
25
        return $this->createQueryBuilder('s')
26
            ->where('s.endedAt >= :begin_at')
27
            ->andWhere('s.beginAt <= :ended_at')
28
            ->setParameters([
29
                'begin_at' => $beginAt->format('Y-m-d H:i:s'),
30
                'ended_at' => $endedAt->format('Y-m-d H:i:s')
31
            ])
32
            ->getQuery()
33
            ->getResult();
34
    }
35
}