UnsetValue   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Composer\Config\Merger\Modifier;
6
7
/**
8
 * Object that represents the removal of array value while performing {@see Merger::merge()}.
9
 *
10
 * Usage example:
11
 *
12
 * ```php
13
 * $array1 = [
14
 *     'ids' => [
15
 *         1,
16
 *     ],
17
 *     'validDomains' => [
18
 *         'example.com',
19
 *         'www.example.com',
20
 *     ],
21
 * ];
22
 *
23
 * $array2 = [
24
 *     'ids' => [
25
 *         2,
26
 *     ],
27
 *     'validDomains' => new \Yiisoft\Composer\Config\Merger\Modifier\UnsetValue(),
28
 * ];
29
 *
30
 * $result = Merger::merge($array1, $array2);
31
 * ```
32
 *
33
 * The result will be
34
 *
35
 * ```php
36
 * [
37
 *     'ids' => [
38
 *         1,
39
 *         2,
40
 *     ],
41
 * ]
42
 * ```
43
 */
44
final class UnsetValue implements ModifierInterface
45
{
46 2
    public function apply(array $data, $key): array
47
    {
48 2
        unset($data[$key]);
49
50 2
        return $data;
51
    }
52
}
53