Completed
Push — master ( 8400ab...233003 )
by
unknown
02:27
created

MongoAdapter   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getCursor() 0 4 1
A getNbResults() 0 4 1
A getSlice() 0 7 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
 * MongoAdapter.
16
 *
17
 * @author Sergey Ponomaryov <[email protected]>
18
 */
19
class MongoAdapter implements AdapterInterface
20
{
21
    private $cursor;
22
23
    /**
24
     * Constructor.
25
     *
26
     * @param \MongoCursor $cursor The cursor.
27
     */
28
    public function __construct(\MongoCursor $cursor)
29
    {
30
        $this->cursor = $cursor;
31
    }
32
33
    /**
34
     * Returns the cursor.
35
     *
36
     * @return \MongoCursor The cursor.
37
     */
38
    public function getCursor()
39
    {
40
        return $this->cursor;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function getNbResults()
47
    {
48
        return $this->cursor->count();
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function getSlice($offset, $length)
55
    {
56
        $this->cursor->limit($length);
57
        $this->cursor->skip($offset);
58
59
        return $this->cursor;
60
    }
61
}
62