Completed
Pull Request — develop (#69)
by
unknown
01:20
created

ArrayHelper::toTableRowsInput()   B

Complexity

Conditions 6
Paths 6

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 8.8571
c 0
b 0
f 0
cc 6
eloc 9
nc 6
nop 1
1
<?php
2
3
namespace Nord\Lumen\Elasticsearch\Helpers;
4
5
/**
6
 * Class ReindexResponseTransformer
7
 * @package Nord\Lumen\Elasticsearch\Helpers
8
 */
9
class ArrayHelper
10
{
11
    /**
12
     * Transform response array to symfony table rows input
13
     * @param array $response
14
     *
15
     * @return array
16
     */
17
    public static function toTableRowsInput(array $response)
18
    {
19
        $rows = [];
20
        foreach ($response as $key => $value) {
21
            if (is_array($value)) {
22
                $rows[] = [$key, count($value) ? http_build_query($value, '', ',') : '[]'];
23
            } elseif (is_bool($value)) {
24
                $rows[] = [$key, $value ? 'true' : 'false'];
25
            } else {
26
                $rows[] = [$key, strval($value)];
27
            }
28
        }
29
        return $rows;
30
    }
31
}
32