Passed
Push — master ( ddf312...be26c9 )
by Luiz Kim
02:13
created

PeopleRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getPeopleLink() 0 15 2
1
<?php
2
3
namespace ControleOnline\Repository;
4
5
use ControleOnline\Entity\People;
6
use ControleOnline\Entity\Status;
0 ignored issues
show
Bug introduced by
The type ControleOnline\Entity\Status 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...
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
0 ignored issues
show
Bug introduced by
The type Doctrine\Bundle\Doctrine...ServiceEntityRepository 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 Doctrine\ORM\Query\ResultSetMapping;
0 ignored issues
show
Bug introduced by
The type Doctrine\ORM\Query\ResultSetMapping 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...
9
use Doctrine\Persistence\ManagerRegistry;
0 ignored issues
show
Bug introduced by
The type Doctrine\Persistence\ManagerRegistry 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...
10
11
12
/**
13
 * @method People|null find($id, $lockMode = null, $lockVersion = null)
14
 * @method People|null findOneBy(array $criteria, array $orderBy = null)
15
 * @method People[]    findAll()
16
 * @method People[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
17
 */
18
class PeopleRepository extends ServiceEntityRepository
19
{
20
    public function __construct(ManagerRegistry $registry)
21
    {
22
        parent::__construct($registry, People::class);
23
    }
24
25
    public function getPeopleLink(People $people, $linkType, $maxResults = null)
26
    {
27
        $queryBuilder = $this->getEntityManager()->createQueryBuilder();
28
        $queryBuilder->select('pl')
29
            ->from('ControleOnline\Entity\PeopleLink', 'pl')
30
            ->where('pl.people = :peopleId')
31
            ->andWhere('pl.link_type = :linkType')
32
            ->setParameter('peopleId', $people->getId())
33
            ->setParameter('linkType', $linkType);
34
35
        if ($maxResults) {
36
            $queryBuilder->setMaxResults(1);
37
            return $queryBuilder->getQuery()->getOneOrNullResult();
38
        } else {
39
            return $queryBuilder->getQuery()->getResult();
40
        }
41
    }
42
}
43