FixedAdapter::getSlice()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 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
 * Provides you with an adapter that returns always the same data.
16
 *
17
 * Best used when you need to do a custom paging solution and don't
18
 * want to implement a full adapter for a one-off use case.
19
 *
20
 * @author Jordi Boggiano <[email protected]>
21
 */
22
class FixedAdapter implements AdapterInterface
23
{
24
    private $nbResults;
25
    private $results;
26
27
    /**
28
     * @param int                $nbResults
29
     * @param array|\Traversable $results
30
     */
31 4
    public function __construct($nbResults, $results)
32
    {
33 4
        $this->nbResults = $nbResults;
34 4
        $this->results = $results;
35 4
    }
36
37
    /**
38
     * {@inheritDoc}
39
     */
40 1
    public function getNbResults()
41
    {
42 1
        return $this->nbResults;
43
    }
44
45
    /**
46
     * {@inheritDoc}
47
     */
48 2
    public function getSlice($offset, $length)
49
    {
50 2
        return $this->results;
51
    }
52
}
53