Parser::get()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 12
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 15
ccs 12
cts 12
cp 1
rs 9.4285
cc 3
eloc 10
nc 3
nop 1
crap 3
1
<?php
2
namespace Kwkm\MkLiveStatusClient;
3
4
/**
5
 * Class Parser
6
 *
7
 * @package Kwkm\MkLiveStatusClient
8
 * @author Takehiro Kawakami <[email protected]>
9
 * @license MIT
10
 */
11
class Parser
12
{
13 2
    public function decode($response)
14
    {
15 2
        return json_decode($response, true);
16
    }
17
18
    /**
19
     * ヘッダをキーとした配列として読み込む
20
     *
21
     * @param string $response
22
     * @return array
23
     */
24 1
    public function get($response)
25
    {
26 1
        $json = $this->decode($response);
27 1
        $header = array_shift($json);
28 1
        $result = array();
29 1
        foreach ($json as $row) {
30 1
            $work = array();
31 1
            foreach ($row as $key => $value) {
32 1
                $work[$header[$key]] = $value;
33 1
            }
34 1
            $result[] = $work;
35 1
        }
36
37 1
        return $result;
38
    }
39
}
40