ArrayAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

4 Methods

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