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

TransactionalUuidCrudRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 25
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findByUuid() 0 10 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 TransactionalUuidCrudRepository extends TransactionalCrudRepository implements UuidCrudRepositoryInterface
11
{
12
    /**
13
     * {@inheritdoc}
14
     */
15 6
    public function findByUuid(string $uuid): ?object
16
    {
17 6
        return $this->getTransactionManager()->transactional(
18
            function () use ($uuid) {
19 6
                $query = $this->createFindByUuidQuery($uuid);
20
21 6
                return $query->getOneOrNullResult();
22 6
            }
23
        );
24
    }
25
26 6
    protected function createFindByUuidQuery(string $uuid): Query
27
    {
28 6
        $queryBuilder = $this->createQueryBuilder('entity');
29 6
        $queryBuilder->where('entity.uuid = :uuid');
30 6
        $queryBuilder->setParameter('uuid', $uuid);
31
32 6
        return $queryBuilder->getQuery();
33
    }
34
}
35