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

resolveOperationPath()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 3
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