Passed
Pull Request — master (#62)
by Sergei
02:11
created

RemoveAllKeys   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Arrays\Collection\Modifier;
6
7
use Yiisoft\Arrays\Collection\Modifier\ModifierInterface\DataModifierInterface;
8
use Yiisoft\Arrays\Collection\Modifier\ModifierInterface\PrioritizedModifierInterface;
0 ignored issues
show
Bug introduced by
The type Yiisoft\Arrays\Collectio...itizedModifierInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
9
10
/**
11
 * Re-indexes an array numerically, i. e. removes all information about array keys. Based on {@see array_values}.
12
 *
13
 * Simple usage:
14
 *
15
 * ```php
16
 * $removeKeys = new RemoveAllKeys();
17
 *
18
 * // [1, 2]
19
 * $result = $removeKeys->apply(['a' => 1, 'b' => 2]);
20
 * ```
21
 *
22
 * Usage with merge:
23
 *
24
 * ```php
25
 * $a = [
26
 *     'name' => 'Yii',
27
 *     'version' => '1.0',
28
 * ];
29
 * $b = new ArrayCollection(
30
 *     [
31
 *         'version' => '3.0',
32
 *         'options' => [],
33
 *     ],
34
 *     new RemoveAllKeys()
35
 * );
36
 *
37
 * // [
38
 * //     'Yii',
39
 * //     '3.0',
40
 * //     [],
41
 * // ],
42
 * $result = ArrayHelper::merge($a, $b);
43
 * ```
44
 */
45
final class RemoveAllKeys extends Modifier implements DataModifierInterface
46
{
47
    protected int $priority = Modifier::PRIORITY_LOW;
48
49 4
    public function apply(array $data): array
50
    {
51 4
        return array_values($data);
52
    }
53
}
54