Passed
Pull Request — main (#123)
by Andrey
38:21 queued 23:20
created

Keyable::getKeysOnly()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 15
ccs 0
cts 0
cp 0
crap 12
rs 10
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 28
 * @author Andrey Helldar <[email protected]>
10
 *
11 28
 * @copyright 2021 Andrey Helldar
12
 *
13 28
 * @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
    protected function getKeysOnly(array $array): array
25
    {
26
        $result = [];
27
28
        foreach ($array as $key => $value) {
29
            if (is_array($value)) {
30
                $result[$key] = $this->getKeysOnly($value);
31
32
                continue;
33
            }
34
35
            array_push($result, $key);
36
        }
37
38
        return $result;
39
    }
40
}
41