Completed
Push — master ( 89612e...daf835 )
by Axel
02:08
created

SprintRepository::getPreviousSprint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
ccs 0
cts 6
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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 getPreviousSprint()
24
    {
25
        return $this->createQueryBuilder('s')
26
            ->where('s.endedAt <= :now')
27
            ->setParameters(['now' => (new \DateTime())->format('Y-m-d H:i:s')])
28
            ->getQuery()
29
            ->getOneOrNullResult();
30
    }
31
    
32
    public function getSprintByPeriod(\DateTime $beginAt, \DateTime $endedAt)
33
    {
34
        return $this->createQueryBuilder('s')
35
            ->where('s.endedAt >= :begin_at')
36
            ->andWhere('s.beginAt <= :ended_at')
37
            ->setParameters([
38
                'begin_at' => $beginAt->format('Y-m-d H:i:s'),
39
                'ended_at' => $endedAt->format('Y-m-d H:i:s')
40
            ])
41
            ->getQuery()
42
            ->getResult();
43
    }
44
}