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

MongoAdapter::getCursor()   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 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
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
 * 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