DoctrineODMPhpcrAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getQueryBuilder() 0 4 1
A getNbResults() 0 4 1
A getSlice() 0 8 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\ODM\PHPCR\Query\Builder\QueryBuilder;
15
use Doctrine\ODM\PHPCR\Query\Query;
16
17
/**
18
 * Pagerfanta adapter for Doctrine PHPCR-ODM.
19
 *
20
 * @author David Buchmann <[email protected]>
21
 */
22
class DoctrineODMPhpcrAdapter implements AdapterInterface
23
{
24
    private $queryBuilder;
25
26
    /**
27
     * Constructor.
28
     *
29
     * @param QueryBuilder $queryBuilder A Doctrine PHPCR-ODM query builder.
30
     */
31 3
    public function __construct(QueryBuilder $queryBuilder)
32
    {
33 3
        $this->queryBuilder = $queryBuilder;
34 3
    }
35
36
    /**
37
     * Returns the query builder.
38
     *
39
     * @return QueryBuilder The query builder.
40
     */
41 1
    public function getQueryBuilder()
42
    {
43 1
        return $this->queryBuilder;
44
    }
45
46
    /**
47
     * {@inheritdoc}
48
     */
49 1
    public function getNbResults()
50
    {
51 1
        return $this->queryBuilder->getQuery()->execute(null, Query::HYDRATE_PHPCR)->getRows()->count();
0 ignored issues
show
Unused Code introduced by
The call to QueryInterface::execute() has too many arguments starting with null.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
52
    }
53
54
    /**
55
     * {@inheritdoc}
56
     */
57 1
    public function getSlice($offset, $length)
58
    {
59 1
        return $this->queryBuilder
0 ignored issues
show
Bug introduced by
The method setMaxResults() does not seem to exist on object<PHPCR\Query\QueryInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
60 1
            ->getQuery()
61 1
            ->setMaxResults($length)
62 1
            ->setFirstResult($offset)
63 1
            ->execute();
64
    }
65
}
66