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

RouteDataProvider::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Silverback\ApiComponentBundle\DataProvider\Item;
4
5
use ApiPlatform\Core\DataProvider\ItemDataProviderInterface;
6
use ApiPlatform\Core\DataProvider\RestrictedDataProviderInterface;
7
use Silverback\ApiComponentBundle\Entity\Route\Route;
8
use Silverback\ApiComponentBundle\Repository\RouteRepository;
9
10
class RouteDataProvider implements ItemDataProviderInterface, RestrictedDataProviderInterface
11
{
12
    private $routeRepository;
13
14
    public function __construct(RouteRepository $routeRepository)
15
    {
16
        $this->routeRepository = $routeRepository;
17
    }
18
19
    public function getItem(string $resourceClass, $id, string $operationName = null, array $context = [])
20
    {
21
        return $this->routeRepository->findOneByIdOrRoute($id);
22
    }
23
24
    public function supports(string $resourceClass, string $operationName = null, array $context = []): bool
25
    {
26
        return $resourceClass === Route::class;
27
    }
28
}
29