FixtureRepository::findByGameDate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace OSS\CoreBundle\Repository;
4
5
use Doctrine\ORM\EntityRepository;
6
use OSS\CoreBundle\Entity\Fixture;
7
use OSS\CoreBundle\Entity\GameDate;
8
use OSS\CoreBundle\Entity\League;
9
10
class FixtureRepository extends EntityRepository
11
{
12
    /**
13
     * @param GameDate $gameDate
14
     *
15
     * @return Fixture[]
16
     */
17
    public function findByGameDate(GameDate $gameDate)
18
    {
19
        return $this->findBy(array('season' => $gameDate->getSeason(), 'week' => $gameDate->getWeek()));
20
    }
21
22
    /**
23
     * @param League $league
24
     * @param int $season
25
     *
26
     * @return Fixture[]
27
     */
28
    public function findByLeagueAndSeasonWithEvents(League $league, $season)
29
    {
30
        $qb = $this->_em->createQueryBuilder();
31
        $qb->select(array('f', 'e'));
32
        $qb->from('CoreBundle:Fixture', 'f');
33
        $qb->where('f.league = :league');
34
        $qb->setParameter('league', $league->getId());
35
        $qb->andWhere('f.season = :season');
36
        $qb->setParameter('season', $season);
37
        $qb->join('f.events', 'e');
38
39
        return $qb->getQuery()->getResult();
40
    }
41
}
42