ArrayableHelper::processArray()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 15
ccs 11
cts 11
cp 1
rs 9.9332
cc 4
nc 4
nop 1
crap 4
1
<?php
2
/*
3
 * This file is part of the Bushido\Foundation package.
4
 *
5
 * (c) Wojciech Nowicki <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE.md
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Bushido\Foundation\Helpers;
12
13
use Bushido\Foundation\Contracts\Arrayable;
14
15
class ArrayableHelper
16
{
17 24
    public static function processArray(array $data): array
18
    {
19 24
        $rtn = [];
20 24
        foreach ($data as $k => $v) {
21 24
            if ($v instanceof Arrayable) {
22 6
                $rtn[$k] = $v->toArray();
23 6
                continue;
24
            }
25 24
            if (is_array($v)) {
26 6
                $rtn[$k] = self::processArray($v);
27 6
                continue;
28
            }
29 24
            $rtn[$k] = $v;
30
        }
31 24
        return $rtn;
32
    }
33
}
34