ArrayUtils   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
eloc 5
c 1
b 1
f 0
dl 0
loc 52
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A insert() 0 3 1
A pluck() 0 3 1
A flatten() 0 3 1
A transpose() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rico\Lib;
6
7
use Rico\Slib\ArrayUtils as StaticArrayUtils;
8
9
class ArrayUtils
10
{
11
    /**
12
     * Extracts each element of a $multidimensionalArray in a single list.
13
     *
14
     * @param array<array> $multidimensionalArray
15
     *
16
     * @return array<Object>
17
     */
18
    public function flatten(array $multidimensionalArray): array
19
    {
20
        return StaticArrayUtils::flatten($multidimensionalArray);
21
    }
22
23
    /**
24
     * Inserts an element $needle at the $index position in the $haystack, conserving the order and moving other element in the way.\n
25
     * Careful, keys will not be preserved.
26
     *
27
     * @param mixed $needle
28
     * @param int $index
29
     * @param array<mixed> $haystack
30
     *
31
     * @return array<mixed>
32
     */
33
    public static function insert($needle, int $index, array $haystack): array
34
    {
35
        return StaticArrayUtils::insert($needle, $index, $haystack);
36
    }
37
38
    /**
39
     * Extracts all $property values from a multidimensional $multidimensionalArray.
40
     *
41
     * @param array<array> $multidimensionalArray
42
     * @param string  $property
43
     *
44
     * @return array<Object>
45
     */
46
    public function pluck(array $multidimensionalArray, string $property): array
47
    {
48
        return StaticArrayUtils::pluck($multidimensionalArray, $property);
49
    }
50
51
    /**
52
     * Transforms multiple $similarArrays into key-valued arrays.
53
     *
54
     * @param mixed[] $similarArrays
55
     *
56
     * @return mixed[]
57
     */
58
    public function transpose(array $similarArrays): array
59
    {
60
        return StaticArrayUtils::transpose($similarArrays);
61
    }
62
}
63