PropelAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 50
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1
ccs 15
cts 15
cp 1
rs 10

4 Methods

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