Completed
Pull Request — master (#997)
by Antoine
03:23
created

IriConverterTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateIdentifiersUrl() 0 12 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\Bridge\Symfony\Routing;
13
14
trait IriConverterTrait
15
{
16
    /**
17
     * Generate the identifier url.
18
     *
19
     * @param array $identifiers
20
     *
21
     * @return string[]
22
     */
23
    private function generateIdentifiersUrl(array $identifiers): array
24
    {
25
        if (1 === count($identifiers)) {
26
            return [rawurlencode(array_values($identifiers)[0])];
27
        }
28
29
        foreach ($identifiers as $name => $value) {
30
            $identifiers[$name] = sprintf('%s=%s', $name, $value);
31
        }
32
33
        return $identifiers;
34
    }
35
}
36