Completed
Push — master ( 6083ab...ca790f )
by Philip
02:35
created

OrmUuidEntityRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 25
rs 10

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
class OrmUuidEntityRepository extends OrmEntityRepository
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public function findByUuid($uuid)
11
    {
12
        return $this->getTransactionManager()->transactional(
13
            function () use ($uuid) {
14
                $query = $this->createFindByUuidQuery($uuid);
15
16
                return $query->getSingleResult();
17
            }
18
        );
19
    }
20
21
    protected function createFindByUuidQuery($uuid)
22
    {
23
        $queryBuilder = $this->createQueryBuilder('entity');
24
        $queryBuilder->where('entity.uuid = :uuid');
25
        $queryBuilder->setParameter('uuid', $uuid);
26
27
        return $queryBuilder->getQuery();
28
    }
29
}
30