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

SprintRepository::getCurrentSprint()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 9.9666
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 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
}