SettingRepository::getOneByCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
namespace App\Repository;
4
5
use App\Entity\Setting;
6
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
7
use Symfony\Bridge\Doctrine\RegistryInterface;
8
9
/**
10
 * Class SettingRepository.
11
 *
12
 * @package App\Repository
13
 */
14
class SettingRepository extends ServiceEntityRepository
15
{
16
    /**
17
     * SettingRepository constructor.
18
     *
19
     * @param RegistryInterface $registry
20
     */
21
    public function __construct(RegistryInterface $registry)
22
    {
23
        parent::__construct($registry, Setting::class);
24
    }
25
26
    /**
27
     * @param string $code
28
     *
29
     * @return mixed
30
     */
31
    public function getOneByCode(string $code)
32
    {
33
        return $this->createQueryBuilder('s')
34
            ->where('s.code = :code')->setParameter('code', $code)
35
            ->setMaxResults(1)
36
            ->getQuery()
37
            ->getOneOrNullResult()
38
        ;
39
    }
40
}
41