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

RouteDataProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 5
dl 0
loc 17
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 3 1
A __construct() 0 3 1
A getItem() 0 3 1
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