DoctrineCollectionAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

4 Methods

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