Completed
Pull Request — master (#211)
by
unknown
03:46
created

Propel2Adapter::getQuery()   A

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 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Pagerfanta package.
5
 *
6
 * (c) Pablo Díez <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Pagerfanta\Adapter;
13
14
/**
15
 * Propel2Adapter.
16
 *
17
 * @author Raphael YAN <[email protected]>
18
 */
19
class Propel2Adapter implements AdapterInterface
20
{
21
    private $query;
22
23
    /**
24
     * Constructor.
25
     *
26
     * @param \ModelCriteria $query
27
     */
28
    public function __construct($query)
29
    {
30
        $this->query = $query;
31
    }
32
33
    /**
34
     * Returns the query.
35
     *
36
     * @return \ModelCriteria
37
     */
38
    public function getQuery()
39
    {
40
        return $this->query;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getNbResults()
47
    {
48
        $q = clone $this->getQuery();
49
50
        $q->offset(0);
51
52
        return $q->count();
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function getSlice($offset, $length)
59
    {
60
        $q = clone $this->getQuery();
61
62
        $q->limit($length);
63
        $q->offset($offset);
64
65
        return $q->find();
66
    }
67
}
68