Passed
Push — master ( aec349...e9c1f2 )
by Alexander
04:11
created

ReverseValues   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
eloc 2
c 1
b 0
f 0
dl 0
loc 5
ccs 2
cts 2
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config\Merger\Modifier;
6
7
/**
8
 * Class ReverseValues
9
 *
10
 * This modifier reverses array values after merge.
11
 *
12
 * It should be specified as
13
 *
14
 * ```php
15
 * ReverseValues::class => new ReverseValues(),
16
 * ```
17
 *
18
 * Usage example:
19
 *
20
 * ```php
21
 *
22
 * use Yiisoft\Composer\Config\Merger\ReverseValues;
23
 *
24
 * $array1 = [
25
 *     'paths' => [
26
 *         '/tmp/tmp',
27
 *         ReverseValues::class => new ReverseValues(),
28
 *     ],
29
 * ];
30
 *
31
 * $array2 = [
32
 *     'paths' => [
33
 *         '/usr/bin',
34
 *     ],
35
 * ];
36
 *
37
 * $result = Merger::merge($array1, $array2);
38
 * ```
39
 *
40
 * The result will be
41
 *
42
 * ```php
43
 * [
44
 *     'paths' => [
45
 *         '/usr/bin',
46
 *         '/tmp/tmp',
47
 *     ],
48
 * ]
49
 * ```
50
 */
51
class ReverseValues implements ModifierInterface
52
{
53 2
    public function apply(array $data, $key): array
54
    {
55 2
        return array_reverse($data);
56
    }
57
}
58