Completed
Push — master ( 9d818b...bc28b8 )
by FX
03:09
created

ProjectRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A refidExists() 0 14 2
1
<?php
2
/**
3
 * Copyright (c) 2017 Francois-Xavier Soubirou.
4
 *
5
 * This file is part of ci-report.
6
 *
7
 * ci-report is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU General Public License as published by
9
 * the Free Software Foundation, either version 3 of the License, or
10
 * (at your option) any later version.
11
 *
12
 * ci-report is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU General Public License
18
 * along with ci-report. If not, see <http://www.gnu.org/licenses/>.
19
 */
20
declare(strict_types=1);
21
22
namespace AppBundle\Repository;
23
24
use Doctrine\ORM\EntityRepository;
25
26
/**
27
 * Project repository class.
28
 *
29
 * @category  ci-report app
30
 *
31
 * @author    Francois-Xavier Soubirou <[email protected]>
32
 * @copyright 2017 Francois-Xavier Soubirou
33
 * @license   http://www.gnu.org/licenses/   GPLv3
34
 *
35
 * @see      https://ci-report.io
36
 */
37
class ProjectRepository extends EntityRepository
38
{
39
    /**
40
     * Check if refid already exists.
41
     *
42
     * @param string $refid RefId to test
43
     *
44
     * @return bool
45
     */
46
    public function refidExists(string $refid): bool
47
    {
48
        $qb = $this->createQueryBuilder('p')
49
            ->select('count(p.id)')
50
            ->where('p.refid = :refid')
51
            ->setParameter('refid', $refid);
52
53
        $result = $qb->getQuery()->getSingleScalarResult();
54
55
        if ($result > 0) {
56
            return true;
57
        }
58
59
        return false;
60
    }
61
}
62