Passed
Push — master ( 641929...562012 )
by Alexey
06:04 queued 12s
created

JsonUtil::recursiveJson()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 7
cp 0
rs 10
cc 3
nc 3
nop 2
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * Copyright (c) Ne-Lexa
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 *
11
 * @see https://github.com/Ne-Lexa/google-play-scraper
12
 */
13
14
namespace Nelexa\GPlay\Util;
15
16
class JsonUtil
17
{
18
    public static function recursiveJson($json, string $path = ''): string
19
    {
20
        if (\is_array($json)) {
21
            $return = '';
22
            foreach ($json as $key => $i) {
23
                $return .= self::recursiveJson($i, $path . '[' . $key . ']');
24
            }
25
26
            return $return;
27
        }
28
29
        return $path . ' => ' . $json . \PHP_EOL;
30
    }
31
}
32