DefaultRepository   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A count() 0 11 3
B pagerfanta() 0 18 5
1
<?php
2
3
4
namespace Doctrs\SonataImportBundle\Repository;
5
6
7
use Doctrine\ORM\EntityRepository;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\EntityRepository was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Symfony\Component\HttpFoundation\Request;
9
10
class DefaultRepository extends EntityRepository {
11
12
    public function pagerfanta(Request $request) {
13
        $sql = $this->createQueryBuilder('data');
14
        $sql->select('data');
15
        switch ($request->get('type', 'all')) {
16
            case 'success':
17
                $sql->where('data.status = 1 or data.status = 2');
18
                break;
19
            case 'new':
20
                $sql->where('data.status = 1');
21
                break;
22
            case 'update':
23
                $sql->where('data.status = 2');
24
                break;
25
            case 'error':
26
                $sql->where('data.status = 3');
27
                break;
28
        }
29
        return $sql->getQuery();
30
    }
31
32
    public function count(array $where = []) {
33
        $sql = $this->createQueryBuilder('data');
34
        $sql->select('COUNT(data)');
35
        if (sizeof($where)) {
0 ignored issues
show
Bug introduced by
The call to sizeof() has too few arguments starting with mode. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        if (/** @scrutinizer ignore-call */ sizeof($where)) {

This check compares calls to functions or methods with their respective definitions. If the call has less 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. Please note the @ignore annotation hint above.

Loading history...
36
            foreach ($where as $key => $value) {
37
                $sql->andWhere('data.' . $key . ' = :' . $key);
38
                $sql->setParameter($key, $value);
39
            }
40
        }
41
42
        return $sql->getQuery()->getSingleScalarResult();
43
    }
44
45
}
46