Passed
Push — 10.x ( 64cb8f...6737cd )
by Andrey
02:16
created

Keyable::getKeysOnly()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 15
ccs 8
cts 8
cp 1
crap 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the "andrey-helldar/laravel-lang-publisher" project.
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * @author Andrey Helldar <[email protected]>
10
 *
11
 * @copyright 2021 Andrey Helldar
12
 *
13
 * @license MIT
14
 *
15
 * @see https://github.com/andrey-helldar/laravel-lang-publisher
16
 */
17
18
declare(strict_types=1);
19
20
namespace Helldar\LaravelLangPublisher\Concerns;
21
22
trait Keyable
23
{
24 62
    protected function getKeysOnly(array $array): array
25
    {
26 62
        $result = [];
27
28 62
        foreach ($array as $key => $value) {
29 62
            if (is_array($value)) {
30 62
                $result[$key] = $this->getKeysOnly($value);
31
32 62
                continue;
33
            }
34
35 62
            array_push($result, $key);
36
        }
37
38 62
        return $result;
39
    }
40
}
41