Completed
Push — master ( c5110b...a167e6 )
by Valentyn
13:46
created

CountryRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 24
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findOneByCode() 0 6 1
A findAllByName() 0 9 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Countries\Repository;
6
7
use App\Countries\Entity\Country;
8
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
9
use Symfony\Bridge\Doctrine\RegistryInterface;
10
11
/**
12
 * @method Country|null find($id, $lockMode = null, $lockVersion = null)
13
 * @method Country|null findOneBy(array $criteria, array $orderBy = null)
14
 * @method Country[]    findAll()
15
 * @method Country[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
16
 */
17
class CountryRepository extends ServiceEntityRepository
18
{
19
    public function __construct(RegistryInterface $registry)
20
    {
21
        parent::__construct($registry, Country::class);
22
    }
23
24
    public function findOneByCode(string $code): ?Country
25
    {
26
        return $this->findOneBy([
27
            'code' => $code,
28
        ]);
29
    }
30
31
    public function findAllByName(string $name): array
32
    {
33
        return $this->createQueryBuilder('c')
34
            ->select('c')
35
            ->where('c.name LIKE :name')
36
            ->setParameter('name', "%{$name}%")
37
            ->getQuery()
38
            ->getResult();
39
    }
40
}
41