DoctrineMapperAdapter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 50%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A find() 0 15 3
1
<?php
2
/**
3
 * @author Stefano Torresi (http://stefanotorresi.it)
4
 * @license See the file LICENSE.txt for copying permission.
5
 * ************************************************
6
 */
7
8
namespace Thorr\Nonce\DataMapper;
9
10
use InvalidArgumentException;
11
use Ramsey\Uuid\Uuid;
12
use Thorr\Nonce\Entity\Nonce;
13
use Thorr\Persistence\Doctrine\DataMapper\DoctrineAdapter;
14
15
class DoctrineMapperAdapter extends DoctrineAdapter implements NonceMapperInterface
16
{
17
    /**
18
     * @param string|Uuid $uuid
19
     * @param string      $namespace
20
     *
21
     * @return Nonce|null
22
     */
23 1
    public function find($uuid, $namespace)
24
    {
25 1
        if (! $uuid instanceof Uuid) {
26
            try {
27 1
                $uuid = Uuid::fromString($uuid);
28 1
            } catch (InvalidArgumentException $e) {
29 1
                return;
30
            }
31
        }
32
33
        return $this->getObjectManager()->getRepository($this->getEntityClass())->findOneBy([
34
            'uuid'      => $uuid->toString(),
35
            'namespace' => $namespace,
36
        ]);
37
    }
38
}
39