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

ReverseValues::apply()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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