RepositoryUuidCrudService   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 29
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findByUuid() 0 4 1
A findByIdOrUuid() 0 8 2
A getRepository() 0 4 1
1
<?php
2
3
namespace Dontdrinkandroot\Service;
4
5
use Dontdrinkandroot\Entity\UuidHelper;
6
use Dontdrinkandroot\Repository\CrudRepositoryInterface;
7
use Dontdrinkandroot\Repository\UuidCrudRepositoryInterface;
8
use Dontdrinkandroot\Utils\EntityUtils;
9
10
/**
11
 * @author Philip Washington Sorst <[email protected]>
12
 */
13
class RepositoryUuidCrudService extends RepositoryCrudService implements UuidCrudServiceInterface
14
{
15 10
    public function __construct(UuidCrudRepositoryInterface $repository)
16
    {
17 10
        parent::__construct($repository);
18 10
    }
19
20 6
    public function findByUuid(string $uuid): ?object
21
    {
22 6
        return $this->getRepository()->findByUuid($uuid);
23
    }
24
25
    public function findByIdOrUuid($idOrUuid): ?object
26
    {
27
        if (EntityUtils::isUuid($idOrUuid)) {
0 ignored issues
show
Deprecated Code introduced by
The method Dontdrinkandroot\Utils\EntityUtils::isUuid() has been deprecated with message: Use Ramsey\Uuid::isValid instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
28
            return $this->findByUuid($idOrUuid);
29
        }
30
31
        return $this->find($idOrUuid);
32
    }
33
34
    /**
35
     * @return UuidCrudRepositoryInterface
36
     */
37 10
    protected function getRepository(): CrudRepositoryInterface
38
    {
39 10
        return parent::getRepository();
40
    }
41
}
42