Passed
Push — master ( 0bc36a...7fe6b0 )
by Paweł
02:16
created

array_key_first()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 2
b 0
f 0
nc 2
nop 1
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Wszetko Sitemap.
7
 *
8
 * (c) Paweł Kłopotek-Główczewski <[email protected]>
9
 *
10
 * This source file is subject to the MIT license that is bundled
11
 * with this source code in the file LICENSE.
12
 */
13
14
if (!function_exists('array_key_first')) {
15
    /**
16
     * Gets the first key of an array.
17
     *
18
     * @param array $arr
19
     *
20
     * @return null|string
21
     */
22
    function array_key_first(array $arr): ?string
23
    {
24
        foreach ($arr as $key => $unused) {
25
            return $key;
26
        }
27
28
        return null;
29
    }
30
}
31