Completed
Push — master ( 122cbf...89c382 )
by
unknown
09:49
created

Propel2Adapter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 4
c 2
b 0
f 1
lcom 1
cbo 1
dl 0
loc 52
ccs 14
cts 14
cp 1
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getQuery() 0 4 1
A getNbResults() 0 8 1
A getSlice() 0 9 1
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
use Propel\Runtime\ActiveQuery\ModelCriteria;
15
16
/**
17
 * Propel2Adapter.
18
 *
19
 * @author Raphael YAN <[email protected]>
20
 */
21
class Propel2Adapter implements AdapterInterface
22
{
23
    /**
24
     * @var ModelCriteria $query
25
     */
26
    private $query;
27
28
    /**
29
     * Constructor.
30
     *
31
     * @param ModelCriteria $query
32
     */
33 3
    public function __construct(ModelCriteria $query)
34
    {
35 3
        $this->query = $query;
36 3
    }
37
38
    /**
39
     * Returns the query.
40
     *
41
     * @return ModelCriteria
42
     */
43 3
    public function getQuery()
44
    {
45 3
        return $this->query;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 1
    public function getNbResults()
52
    {
53 1
        $q = clone $this->getQuery();
54
55 1
        $q->offset(0);
56
57 1
        return $q->count();
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63 1
    public function getSlice($offset, $length)
64
    {
65 1
        $q = clone $this->getQuery();
66
67 1
        $q->limit($length);
68 1
        $q->offset($offset);
69
70 1
        return $q->find();
71
    }
72
}
73