EntityService::getItems()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Polder Knowledge / entityservice-zend-paginator (https://polderknowledge.com)
4
 *
5
 * @link https://github.com/polderknowledge/entityservice-zend-paginator for the canonical source repository
6
 * @copyright Copyright (c) 2016 Polder Knowledge (https://polderknowledge.com)
7
 * @license https://github.com/polderknowledge/entityservice-zend-paginator/blob/master/LICENSE.md MIT
8
 */
9
10
namespace PolderKnowledge\EntityService\Paginator\Adapter;
11
12
use Doctrine\Common\Collections\Criteria;
13
use PolderKnowledge\EntityService\EntityServiceInterface;
14
use Zend\Paginator\Adapter\AdapterInterface;
15
16
/**
17
 * Paginator adapter for EntityServices
18
 */
19
class EntityService implements AdapterInterface
20
{
21
    /**
22
     * EntityService used to fetch adapter
23
     *
24
     * @var EntityServiceInterface
25
     */
26
    private $entityService;
27
28
    /**
29
     * Criteria used to fetch entities
30
     *
31
     * @var array|Criteria
32
     */
33
    private $criteria;
34
35
    /**
36
     * Creates a new instance of this class
37
     *
38
     * @param EntityServiceInterface $entityService
39
     * @param Criteria $criteria The criteria to match.
40
     * @param array $order
0 ignored issues
show
Bug introduced by
There is no parameter named $order. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
41
     */
42 6
    public function __construct(EntityServiceInterface $entityService, Criteria $criteria = null)
43
    {
44 6
        $this->entityService = $entityService;
45 6
        $this->criteria = is_object($criteria) ? clone $criteria : Criteria::create();
46 6
    }
47
48
    /**
49
     * {@inhericDoc}
50
     *
51
     * @return int
52
     */
53 3
    public function count()
54
    {
55 3
        return $this->entityService->countBy($this->criteria);
56
    }
57
58
    /**
59
     * {@inhericDoc}
60
     *
61
     * @param  int $offset Page offset
62
     * @param  int $itemCountPerPage Number of items per page
63
     * @return array
64
     */
65 3
    public function getItems($offset, $itemCountPerPage)
66
    {
67 3
        $this->criteria->setFirstResult($offset);
68 3
        $this->criteria->setMaxResults($itemCountPerPage);
69
70 3
        return $this->entityService->findBy($this->criteria);
71
    }
72
}
73