Passed
Push — master ( 87f8af...7889cb )
by Luiz Kim
03:41 queued 01:37
created

PeopleRepository   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 28
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getCompanyPeopleLinks() 0 18 3
A getPeopleLinks() 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 getPeopleLinks(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 = :people')
31
            ->andWhere('pl.link_type = :linkType')
32
            ->setParameter('people', $people->getId())
33
            ->setParameter('linkType', $linkType);
34
35
        if ($maxResults) {
36
            $queryBuilder->setMaxResults($maxResults);
37
            return $queryBuilder->getQuery()->getOneOrNullResult();
38
        } else {
39
            return $queryBuilder->getQuery()->getResult();
40
        }
41
    }
42
43
44
    public function getCompanyPeopleLinks(People $company,  People $people, $linkType = null, $maxResults = null)
45
    {
46
        $queryBuilder = $this->getEntityManager()->createQueryBuilder();
47
        $queryBuilder->select('pl')
48
            ->from('ControleOnline\Entity\PeopleLink', 'pl')
49
            ->where('pl.people = :people')
50
            ->andWhere('pl.company = :company')
51
            ->setParameter('company', $company->getId())
52
            ->setParameter('people', $people->getId());
53
54
        if ($linkType)
55
            $queryBuilder->setParameter('linkType', $linkType)->andWhere('pl.link_type = :linkType');
56
57
        if ($maxResults) {
58
            $queryBuilder->setMaxResults($maxResults);
59
            return $queryBuilder->getQuery()->getOneOrNullResult();
60
        } else {
61
            return $queryBuilder->getQuery()->getResult();
62
        }
63
    }
64
}
65