Parser   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 4
c 4
b 1
f 1
lcom 0
cbo 0
dl 0
loc 29
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A decode() 0 4 1
A get() 0 15 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