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

IriConverterTrait::generateIdentifiersUrl()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

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