Passed
Push — main ( 964870...8374cd )
by Daniel
08:40 queued 03:10
created

UuidUriVariableTransformer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 21
ccs 0
cts 8
cp 0
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A transform() 0 6 2
A supportsTransformation() 0 3 1
A __construct() 0 3 1
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\RamseyUuid\UuidUriVariableTransformer;
15
16
use ApiPlatform\Api\UriVariableTransformerInterface;
17
use ApiPlatform\Exception\InvalidUriVariableException;
18
use ApiPlatform\RamseyUuid\UriVariableTransformer\UuidUriVariableTransformer as BaseUuidUriVariableTransformer;
19
20
/**
21
 * @author Daniel West <[email protected]>
22
 */
23
class UuidUriVariableTransformer implements UriVariableTransformerInterface
24
{
25
    private BaseUuidUriVariableTransformer $decorated;
26
27
    public function __construct(BaseUuidUriVariableTransformer $decorated)
28
    {
29
        $this->decorated = $decorated;
30
    }
31
32
    public function transform($value, array $types, array $context = [])
33
    {
34
        try {
35
            return $this->decorated->transform($value, $types, $context);
36
        } catch (InvalidUriVariableException $exception) {
37
            return $value;
38
        }
39
    }
40
41
    public function supportsTransformation($value, array $types, array $context = []): bool
42
    {
43
        return $this->decorated->supportsTransformation($value, $types, $context);
44
    }
45
}
46