Passed
Push — master ( ab171b...3e1bb9 )
by Philip
14:43
created

UuidCrudRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 18
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findByUuid() 0 6 1
A createFindByUuidQuery() 0 8 1
1
<?php
2
3
namespace Dontdrinkandroot\Repository;
4
5
use Doctrine\ORM\Query;
6
7
/**
8
 * @author Philip Washington Sorst <[email protected]>
9
 */
10
class UuidCrudRepository extends CrudRepository implements UuidCrudRepositoryInterface
11
{
12 2
    public function findByUuid(string $uuid): ?object
13
    {
14 2
        $query = $this->createFindByUuidQuery($uuid);
15
16 2
        return $query->getOneOrNullResult();
17
    }
18
19 2
    protected function createFindByUuidQuery($uuid): Query
20
    {
21 2
        $queryBuilder = $this->createQueryBuilder('entity');
22 2
        $queryBuilder->where('entity.uuid = :uuid');
23 2
        $queryBuilder->setParameter('uuid', $uuid);
24
25 2
        return $queryBuilder->getQuery();
26
    }
27
}
28