Completed
Push — master ( f56ef3...122cbf )
by
unknown
04:46 queued 01:44
created

Propel2Adapter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

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 0
cts 21
cp 0
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
    public function __construct(ModelCriteria $query)
34
    {
35
        $this->query = $query;
36
    }
37
38
    /**
39
     * Returns the query.
40
     *
41
     * @return ModelCriteria
42
     */
43
    public function getQuery()
44
    {
45
        return $this->query;
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    public function getNbResults()
52
    {
53
        $q = clone $this->getQuery();
54
55
        $q->offset(0);
56
57
        return $q->count();
58
    }
59
60
    /**
61
     * {@inheritdoc}
62
     */
63
    public function getSlice($offset, $length)
64
    {
65
        $q = clone $this->getQuery();
66
67
        $q->limit($length);
68
        $q->offset($offset);
69
70
        return $q->find();
71
    }
72
}
73