Completed
Pull Request — master (#666)
by Guilh
03:55
created

CustomOperationPathResolver   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 1
dl 0
loc 21
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A resolveOperationPath() 0 8 2
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[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
namespace ApiPlatform\Core\PathResolver;
13
14
/**
15
 * Resolves the custom operations path.
16
 *
17
 * @author Guilhem N. <[email protected]>
18
 */
19
final class CustomOperationPathResolver implements OperationPathResolverInterface
20
{
21
    private $deferred;
22
23
    public function __construct(OperationPathResolverInterface $deferred)
24
    {
25
        $this->deferred = $deferred;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function resolveOperationPath(string $resourceShortName, array $operation, bool $collection) : string
32
    {
33
        if (isset($operation['path'])) {
34
            return $operation['path'];
35
        }
36
37
        return $this->deferred->resolveOperationPath($resourceShortName, $operation, $collection);
38
    }
39
}
40