IndexRepository   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A findByVacancyId() 0 19 1
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[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
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\SanityBundle\Entity\Repository\Vacancy;
17
18
use Doctrine\ORM\Cache;
19
use Veslo\AppBundle\Entity\Repository\BaseEntityRepository;
20
use Veslo\SanityBundle\Entity\Vacancy\Index;
21
22
/**
23
 * Sanity index repository
24
 */
25
class IndexRepository extends BaseEntityRepository
26
{
27
    /**
28
     * Returns a sanity index instance with all related data for the specified vacancy identifier
29
     *
30
     * @param int $vacancyId Vacancy identifier
31
     *
32
     * @return Index|null
33
     */
34
    public function findByVacancyId(int $vacancyId): ?Index
35
    {
36
        $queryBuilder = $this->createQueryBuilder('e');
37
        $queryBuilder
38
            // fetch join for caching.
39
            ->leftJoin('e.tags', 't')
40
            ->addSelect('t')
41
            ->andWhere($queryBuilder->expr()->eq('e.vacancyId', ':vacancyId'))
42
            ->setParameter('vacancyId', $vacancyId)
43
        ;
44
45
        $query = $queryBuilder->getQuery();
46
        $query
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\ORM\AbstractQuery::useResultCache() has been deprecated: 2.7 Use {@see enableResultCache} and {@see disableResultCache} instead. ( Ignorable by Annotation )

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

46
        /** @scrutinizer ignore-deprecated */ $query

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
47
            ->setCacheable(true)
48
            ->setCacheMode(Cache::MODE_NORMAL)
49
            ->useResultCache(true)
50
        ;
51
52
        return $query->getOneOrNullResult();
53
    }
54
}
55