SettingRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getOneByCode() 0 9 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