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

RemoveKeys::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
 * Removes array keys from the merge result while performing {@see Merger::merge()}.
9
 *
10
 * The modifier should be specified as
11
 *
12
 * ```php
13
 * RemoveKeys::class => new RemoveKeys(),
14
 * ```
15
 *
16
 * ```php
17
 * $a = [
18
 *     'name' => 'Yii',
19
 *     'version' => '1.0',
20
 * ];
21
 *
22
 * $b = [
23
 *    'version' => '1.1',
24
 *    'options' => [],
25
 *    RemoveKeys::class => new RemoveKeys(),
26
 * ];
27
 *
28
 * $result = Merger::merge($a, $b);
29
 * ```
30
 *
31
 * Will result in:
32
 *
33
 * ```php
34
 * [
35
 *     'Yii',
36
 *     '1.1',
37
 *     [],
38
 * ];
39
 */
40
final class RemoveKeys implements ModifierInterface
41
{
42 2
    public function apply(array $data, $key): array
43
    {
44 2
        return array_values($data);
45
    }
46
}
47