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

ArrayHelper   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 6
dl 0
loc 21
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B toTableRowsInput() 0 13 6
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