Test Failed
Push — develop ( 54c2ec...92c10d )
by Daniel
04:31
created

RouteRepository::findOneByIdOrRoute()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 2
nc 2
nop 1
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Silverback\ApiComponentBundle\Repository;
6
7
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
8
use Silverback\ApiComponentBundle\Entity\Route\Route;
9
use Symfony\Bridge\Doctrine\RegistryInterface;
10
11
/**
12
 * @method Route|null find($id, $lockMode = null, $lockVersion = null)
13
 * @method Route|null findOneBy(array $criteria, array $orderBy = null)
14
 * @method Route[]    findAll()
15
 * @method Route[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
16
 */
17
class RouteRepository extends ServiceEntityRepository
18
{
19
    public function __construct(RegistryInterface $registry)
20
    {
21
        parent::__construct($registry, Route::class);
22
    }
23
24
    public function findOneByIdOrRoute(string $idOrRoute)
25
    {
26
        $route = $this->find($idOrRoute);
27
        if ($route) {
28
            return $route;
29
        }
30
        return $this->findOneBy([
31
            'route' => $idOrRoute
32
        ]);
33
    }
34
}
35