Completed
Pull Request — master (#131)
by De Cramer
05:13 queued 02:26
created

RecordQueryBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 42
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getMapRecords() 0 10 1
A getPlayerMapRecords() 0 9 1
1
<?php
2
3
namespace eXpansion\Bundle\LocalRecords\Model;
4
5
/**
6
 * Class RecordQueryBuilder
7
 *
8
 * @author    de Cramer Oliver<[email protected]>
9
 * @copyright 2017 Smile
10
 * @package eXpansion\Bundle\LocalRecords\Query
11
 */
12
class RecordQueryBuilder
13
{
14
    /**
15
     * Get records on a certain map.
16
     *
17
     * @param $mapUid
18
     * @param $nbLaps
19
     * @param $sort
20
     * @param $nbRecords
21
     *
22
     * @return Record[]|\Propel\Runtime\Collection\ObjectCollection
23
     */
24
    public function getMapRecords($mapUid, $nbLaps, $sort, $nbRecords)
25
    {
26
        $query = new RecordQuery();
27
        $query->filterByMapuid($mapUid);
28
        $query->filterByNblaps($nbLaps);
29
        $query->orderByScore($sort);
30
        $query->limit($nbRecords);
31
32
        return $query->find()->getData();
33
    }
34
35
    /**
36
     * Get a players record on a certain map.
37
     *
38
     * @param $mapUid
39
     * @param $nbLaps
40
     * @param $logins
41
     *
42
     * @return Record[]|\Propel\Runtime\Collection\ObjectCollection
43
     */
44
    public function getPlayerMapRecords($mapUid, $nbLaps, $logins)
45
    {
46
        $query = new RecordQuery();
47
        $query->filterByMapuid($mapUid);
48
        $query->filterByNblaps($nbLaps);
49
        $query->filterByPlayerLogins($logins);
50
51
        return $query->find()->getData();
52
    }
53
}