PeopleRepository::getCompanyPeopleLinks()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 18
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 14
c 0
b 0
f 0
nc 4
nop 4
dl 0
loc 18
rs 9.7998
1
<?php
2
3
namespace ControleOnline\Repository;
4
5
use ControleOnline\Entity\People;
6
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...
7
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...
8
9
10
/**
11
 * @method People|null find($id, $lockMode = null, $lockVersion = null)
12
 * @method People|null findOneBy(array $criteria, array $orderBy = null)
13
 * @method People[]    findAll()
14
 * @method People[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
15
 */
16
class PeopleRepository extends ServiceEntityRepository
17
{
18
    public function __construct(ManagerRegistry $registry)
19
    {
20
        parent::__construct($registry, People::class);
21
    }
22
23
    public function getPeopleLinks(People $people, $linkType, $maxResults = null)
24
    {
25
        $queryBuilder = $this->getEntityManager()->createQueryBuilder();
26
        $queryBuilder->select('pl')
27
            ->from('ControleOnline\Entity\PeopleLink', 'pl')
28
            ->where('pl.people = :people')
29
            ->andWhere('pl.link_type = :linkType')
30
            ->setParameter('people', $people->getId())
31
            ->setParameter('linkType', $linkType);
32
33
        if ($maxResults) {
34
            $queryBuilder->setMaxResults($maxResults);
35
            return $queryBuilder->getQuery()->getOneOrNullResult();
36
        } else {
37
            return $queryBuilder->getQuery()->getResult();
38
        }
39
    }
40
41
42
    public function getCompanyPeopleLinks(People $company,  People $people, $linkType = null, $maxResults = null)
43
    {
44
        $queryBuilder = $this->getEntityManager()->createQueryBuilder();
45
        $queryBuilder->select('pl')
46
            ->from('ControleOnline\Entity\PeopleLink', 'pl')
47
            ->where('pl.people = :people')
48
            ->andWhere('pl.company = :company')
49
            ->setParameter('company', $company->getId())
50
            ->setParameter('people', $people->getId());
51
52
        if ($linkType)
53
            $queryBuilder->setParameter('linkType', $linkType)->andWhere('pl.link_type = :linkType');
54
55
        if ($maxResults) {
56
            $queryBuilder->setMaxResults($maxResults);
57
            return $queryBuilder->getQuery()->getOneOrNullResult();
58
        } else {
59
            return $queryBuilder->getQuery()->getResult();
60
        }
61
    }
62
}
63