GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Arr::map()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
namespace Spatie\Regex\Helpers;
4
5
class Arr
6
{
7
    public static function map(array $array, callable $callback): array
8
    {
9
        return array_map($callback, $array);
10
    }
11
12
    public static function transpose(array $array): array
13
    {
14
        if (count($array) === 1) {
15
            $array = static::first($array);
16
17
            return array_map(function ($element) {
18
                return [$element];
19
            }, $array);
20
        }
21
22
        $numHits = count($array[0]);
23
        $groups = array_keys($array);
24
        $result = [];
25
        for ($hit = 0; $hit < $numHits; $hit++) {
26
            $group = [];
27
            foreach ($groups as $groupName) {
28
                $group[$groupName] = $array[$groupName][$hit];
29
            }
30
            $result[] = $group;
31
        }
32
33
        return $result;
34
    }
35
36
    /**
37
     * @param array $array
38
     *
39
     * @return mixed
40
     */
41
    public static function first(array $array)
42
    {
43
        return reset($array);
44
    }
45
}
46