Passed
Push — feature/uploadable ( 7c6d25...a7ed20 )
by Daniel
11:07
created

RouteRepository   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A findOneByIdOrRoute() 0 10 2
1
<?php
2
3
/*
4
 * This file is part of the Silverback API Components Bundle Project
5
 *
6
 * (c) Daniel West <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Silverback\ApiComponentsBundle\Repository\Core;
15
16
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
17
use Doctrine\Persistence\ManagerRegistry;
18
use Silverback\ApiComponentsBundle\Entity\Core\Route;
19
20
/**
21
 * @author Daniel West <[email protected]>
22
 *
23
 * @method Route|null find($id, $lockMode = null, $lockVersion = null)
24
 * @method Route|null findOneBy(array $criteria, array $orderBy = null)
25
 * @method Route[]    findAll()
26
 * @method Route[]    findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
27
 */
28
class RouteRepository extends ServiceEntityRepository
29
{
30 1
    public function __construct(ManagerRegistry $registry)
31
    {
32 1
        parent::__construct($registry, Route::class);
33 1
    }
34
35 1
    public function findOneByIdOrRoute(string $idOrRoute)
36
    {
37 1
        $route = $this->findOneBy([
38 1
            'route' => $idOrRoute,
39
        ]);
40 1
        if ($route) {
41 1
            return $route;
42
        }
43
44 1
        return $this->find($idOrRoute);
45
    }
46
}
47