userAdventureClaimedSteps()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 14
Ratio 100 %

Importance

Changes 0
Metric Value
dl 14
loc 14
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 2
1
<?php
2
3
namespace Badger\Bundle\GameBundle\Doctrine\Repository;
4
5
use Badger\Component\Game\Model\AdventureInterface;
6
use Badger\Component\Game\Repository\AdventureStepCompletionRepositoryInterface;
7
use Badger\Component\User\Model\UserInterface;
8
use Doctrine\ORM\EntityRepository;
9
10
/**
11
 * @author  Adrien Pétremann <[email protected]>
12
 * @license http://opensource.org/licenses/MIT The MIT License (MIT)
13
 */
14
class AdventureStepCompletionRepository extends EntityRepository implements AdventureStepCompletionRepositoryInterface
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19 View Code Duplication
    public function userAdventureCompletedSteps(UserInterface $user, AdventureInterface $adventure)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
    {
21
        $qb = $this->getEntityManager()->createQueryBuilder();
22
        $qb->select('s')
23
            ->from('GameBundle:AdventureStep', 's')
24
            ->leftJoin('s.completions', 'sc')
25
            ->where('sc.user = :user')->setParameter(':user', $user)
26
            ->andWhere('s.adventure = :adventure')->setParameter(':adventure', $adventure)
27
            ->andWhere('sc.pending = 0');
28
29
        $queryResult = $qb->getQuery()->getResult();
30
31
        return $queryResult;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37 View Code Duplication
    public function userAdventureClaimedSteps(UserInterface $user, AdventureInterface $adventure)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
38
    {
39
        $qb = $this->getEntityManager()->createQueryBuilder();
40
        $qb->select('s')
41
            ->from('GameBundle:AdventureStep', 's')
42
            ->leftJoin('s.completions', 'sc')
43
            ->where('sc.user = :user')->setParameter(':user', $user)
44
            ->andWhere('s.adventure = :adventure')->setParameter(':adventure', $adventure)
45
            ->andWhere('sc.pending = 1');
46
47
        $queryResult = $qb->getQuery()->getResult();
48
49
        return $queryResult;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55 View Code Duplication
    public function userCompletedSteps(UserInterface $user)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
56
    {
57
        $qb = $this->getEntityManager()->createQueryBuilder();
58
        $qb->select('a as adventure, COUNT(sc) as completions')
59
            ->from('GameBundle:Adventure', 'a')
60
            ->leftJoin('a.steps', 's')
61
            ->leftJoin('s.completions', 'sc')
62
            ->where('sc.user = :user')->setParameter(':user', $user)
63
            ->andWhere('sc.pending = 0')
64
            ->groupBy('s.adventure');
65
66
        $queryResult = $qb->getQuery()->getResult();
67
68
        return $queryResult;
69
    }
70
}
71