ArrayableHelper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 11
c 1
b 0
f 0
dl 0
loc 17
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A processArray() 0 15 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