Collection   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 29
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getItems() 0 4 1
A __construct() 0 4 1
A count() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule\Paginator\Adapter;
6
7
use Doctrine\Common\Collections\Collection as DoctrineCollection;
8
use Laminas\Paginator\Adapter\AdapterInterface;
9
use function array_values;
10
use function count;
11
12
class Collection implements AdapterInterface
13
{
14
    /** @var Doctrine\Common\Collections\Collection */
15
    protected $collection;
16
17
    /**
18
     * @param mixed[] $collection
19
     */
20 4
    public function __construct(DoctrineCollection $collection)
21
    {
22 4
        $this->collection = $collection;
0 ignored issues
show
Documentation Bug introduced by
It seems like $collection of type object<Doctrine\Common\Collections\Collection> is incompatible with the declared type object<DoctrineModule\Pa...Collections\Collection> of property $collection.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
23 4
    }
24
25
    /**
26
     * {@inheritDoc}
27
     */
28 3
    public function getItems($offset, $itemCountPerPage)
29
    {
30 3
        return array_values($this->collection->slice($offset, $itemCountPerPage));
31
    }
32
33
    /**
34
     * {@inheritDoc}
35
     */
36 1
    public function count()
37
    {
38 1
        return count($this->collection);
39
    }
40
}
41